{C#} C#6酷酷的

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace GrammaOfCS6
{
    class Functions
    {
       public DateTime InitTime { get; } = DateTime.Now;

       public string TypeOfIt => string.Format("{0}", typeof(Functions));

       public int GetMax(int left, int right) => Math.Max(left, right);

       public int GetMin(int left, int right) => Math.Min(left, right);

       public string GetFirstName(string fullname)
       {
           return fullname?.Split(' ')[0];
       }

       public int? GetNameLength(string name)
       {
           return name?.Length;
       }

       public float AddNumber(float x, float y, Func<float, float, float> acc)
       {
           return acc?.Invoke(x, y) ?? (x + y);
       }

       public void PrintParam(string first, string second)
       {
           Console.WriteLine(string.Format("{0}:{1},{2}:{3}", nameof(first), first, nameof(second), second));
       }

       public void Introduce()
       {
           Console.WriteLine("you are calling {0}.{1}", nameof(Functions), nameof(Introduce));
       }

       public void WriteCMain()
       {
           var world = "world";
           var hello = $"hello, {world}";

           var cppHelloWorldProgram = new Dictionary<int, string>
           {
               [10] = $"{HeadOfCMain()}",
               [20] = "    printf(\"hello, world\")",
               [30] = "    return 0;}"
           };


           Console.WriteLine(cppHelloWorldProgram[10]);
           Console.WriteLine(cppHelloWorldProgram[20]);
           Console.WriteLine(cppHelloWorldProgram[30]);
       }

       private string HeadOfCMain()
       {
           return "int main() {";
       }
   }
}
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容