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() {";
}
}
}
网友评论