博文

目前显示的是标签为“c sharp”的博文

JSON & C#

1. System.Text.Json.Utf8JsonReader ref: https://docs.microsoft.com/en-us/dotnet/core/whats-new/dotnet-core-3-0  https://github.com/ysharplanguage/FastJsonParser#Overview 2. Newtonsoft.Json library  using NewTonsoft.Json; //Using Manage NuGet Packages installs Newtonsoft.Json .  Cat cat2 = new Cat(){name="hik",age=3};  string s1= Newtonsoft.Json.JsonConvert . SerializeObject (cat2);   Cat   cat3 = JsonConvert . DeserializeObject <Cat>(JSONstr);   string outStr2 = JsonConvert.SerializeObject(cat2); private string CapitalFirstLetter(string s)  {             try             {                 string rs = char.ToUpper(s[0]) + s.Substring(1);                 return r...

Assembly in C#

1. using System.Reflection.Assembly System.Reflection.AssemblyName name = System.Reflection.Assembly.GetExecutingAssembly().GetName(); //name is {AssemblyNameInProperties, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null} byte[]  key =  name.GetPublicKey(); 2. reflection Assembly assem = typeof (ExampleClass).Assembly; // Create an object from the assembly, passing in the correct number // and type of arguments for the constructor. Object o = assem.CreateInstance( "Example" , false , BindingFlags.ExactBinding, null , new Object[] { 2 }, null , null ); // Make a late-bound call to an instance method of the object. MethodInfo m = assem.GetType( "Example" ).GetMethod( "SampleMethod" ); Object ret = m.Invoke(o, new Object[] { 42 }); Console.WriteLine( "SampleMethod returned {0}." , ret); reference: docs.microsoft.com/en-us/dotnet/api/system.re...