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; } }

Questions about programming?Chat with your personal AI assistant