Skip to content

Instantly share code, notes, and snippets.

@vibs2006
Created August 7, 2023 07:05
Show Gist options
  • Save vibs2006/7fc2695da28bf082617d38603ac63140 to your computer and use it in GitHub Desktop.
Save vibs2006/7fc2695da28bf082617d38603ac63140 to your computer and use it in GitHub Desktop.
C# Small codes
//Get Nullable Type
namespace TestConsoleApp
{
public class PaginationRequestParams
{
public string? page_cursor { get; set; }
public int? count { get; set; }
public string? response_fields { get; set; }
public DateTime? created_to { get; set; }
public DateTime? created_from { get; set; }
public DateTime? modified_to { get; set; }
public DateTime? modified_from { get; set; }
public string? customer_id { get; set; }
public string? StoreKey { get; set; }
}
}
Console.WriteLine("Hello, World!");
Type type = typeof(PaginationRequestParams);
PropertyInfo[] properties = type.GetProperties();
foreach (PropertyInfo property in properties)
{
Console.WriteLine("********************************************************");
if (property.PropertyType.Name.ToLower().Contains("null"))
{
var aa = Nullable.GetUnderlyingType(property.PropertyType);
Console.WriteLine(aa);
}
else
{
Console.WriteLine($"{property.PropertyType.Name}");
}
//Console.WriteLine(JsonConvert.SerializeObject(property, Formatting.Indented));
Console.WriteLine("********************************************************");
}
Console.WriteLine("Completed...");
Console.ReadLine();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment