This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using System; | |
| class Program | |
| { | |
| static void Main() | |
| { | |
| int yas; | |
| yas=Convert.ToInt32(Console.ReadLine()); | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using Newtonsoft.Json; | |
| class Data | |
| { | |
| public string Title { get; set; } | |
| public DateTime SomeTimestamp { get; set; } | |
| public List<int> Numbers { get; set; } = new List<int>(); | |
| } | |
| class Program |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| private IEnumerable<EnumDescriptor> GetEnumDefinitions(IReadOnlyList<FileDescriptor> fileDescriptors) => | |
| fileDescriptors.SelectMany(GetEnumDefinitions); | |
| private IEnumerable<EnumDescriptor> GetEnumDefinitions(FileDescriptor fileDescriptor) => | |
| fileDescriptor.EnumTypes.Concat(fileDescriptor.MessageTypes.SelectMany(GetEnumDefinitions)); | |
| private IEnumerable<EnumDescriptor> GetEnumDefinitions(MessageDescriptor messageDescriptor) => | |
| messageDescriptor.EnumTypes.Concat(messageDescriptor.NestedTypes.SelectMany(GetEnumDefinitions)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using System.Text.Json; | |
| namespace ContosoCrafts.Website.Services; | |
| public class JsonFileProductService | |
| { | |
| public IWebHostEnvironment WebHostEnvironment { get; } | |
| private string JsonFileName => | |
| Path.Combine(WebHostEnvironment.WebRootPath, "data", "products.json"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public string LargestNumber(int num1, int num2) => | |
| num1 > num2 ? "number 1 is the greatest!" | |
| : num2 > num1 ? "number 2 is the greatest!" | |
| : "Both are equal!"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using Microsoft.FeatureManagement; | |
| class Program | |
| { | |
| static void Main() | |
| { | |
| IFeatureManager featureManager = null; | |
| if (featureManager.IsEnabledAsync(nameof(WidgetFeatureFlags.FeatureToggleABC)).Result) | |
| { | |
| Console.WriteLine("Running task with new toggle"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using System; | |
| using System.Collections.Concurrent; | |
| using System.Linq; | |
| using System.Reflection; | |
| public class MyEntity | |
| { | |
| public string Name; | |
| public string MacAddress; | |
| public bool IsIncredible; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using Newtonsoft.Json; | |
| var a = new A("test"); | |
| var asJson = JsonConvert.SerializeObject( | |
| a, | |
| Formatting.None, | |
| new JsonSerializerSettings | |
| { | |
| NullValueHandling = NullValueHandling.Ignore | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using System; | |
| using System.Globalization; | |
| var result = TimeZoneInfo.ConvertTime(DateTime.UtcNow, TimeZoneInfo.Local); | |
| Console.WriteLine(result); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| List<Item?> collection = new List<Item?>(); | |
| foreach (var item in collection) | |
| { | |
| if (item == null) | |
| continue; | |
| if (item.Field == "xyz") | |
| { | |
| Console.WriteLine("Found it"); | |
| } | |
| } |