Generation

generate functionSat, 12 Nov 2022

Serialize an object to json and print an error to a file if that is not possible

public async Task<string> Get(object obj) { try { return JsonConvert.SerializeObject(obj); } catch (Exception ex) { await File.WriteAllTextAsync(@"C:\log.txt", ex.Message); throw; } }

Want to kickstart your project?Use the new AI Studio to create your code