cool hit counter C# reverie/blunder_Intefrankly

C# reverie/blunder


  1. Generic constraints are more powerful. For example, with support for constructor with parameters, enumerations, delegates.
void Foo<T>() where T : new(string, int), enum, delegate
  1. The null determiner allows the assignment of values to attributes/fields.
obj?.Name = "sdf"; //objbecause ofnull And do nothing.
  1. Indexers support generic types.
public T this<T>[int i]
{
    get { return (T)arr[i]; } 
    set { arr[i] = value; }
}
  1. Support for var as the argument type, representing the anonymous type, so that the method can return the anonymous type, and finish with the same var catching the return value, and can intelligently hint at the properties of the returned object, which requires a consistent anonymous type for each return in the method. Currently you can replace it with dynamic, but then there is no more smart tip:.
public static var Create<T1, T2>(T1 arg1, T2 arg2)
{
    return new { Item1 = arg1, Item2 = arg2 };
}
  1. Inline out is supported. This was actually almost implemented in c#6.0, but it didn't end up working out as expected, I guess because of bad handling on variable scopes: the
if (int.TryParse("3", out int i)) // Combining type inference, evenint All allowable omissions
{
    Use(i);
}
  1. Support for static indexers.
public static class Package
{
    static readonly Dictionary<string, int> _dic;

    static Package()
    {
        _dic = new Dictionary<string, int>(3);
        _dic.Add("a", 0);
        _dic.Add("b", 1);
        _dic.Add("c", 2);
    }

    public static int this[string name]
    {
        get { return _dic[name]; }
        set { _dic[name] = value; }
    }
}

// use example
Use(Package["b"]);
  1. Support for compiling to native exe/dll, to be precise this is a reverie for the compiler. I'm not so much for performance as I am for not wanting to run the library, and for not exposing our source code to the stream of .net reflactor naked. There is a .net native, but it's store app only and it seems too supervised.
  2. The do-until loop syntax is supported, only do-while is unhappy. It doesn't make sense that C#, which is known for its syntax, wouldn't support it when VB and Powershell are the little guys that do.

That's all for now, I'll add new ideas as they come up.


Recommended>>
1、Break the black box MIT develops transparent AI system that thinks like a human
2、Survey Mobile phones overtake computers as the dominant device for Internet access in Japan
3、3 firsts to speed up online government
4、Leveraging takeaways games and online cars Google Maps proposes a plan to cash in
5、By the end of June there are 13 spots left in the Networks Python development class

    已推荐到看一看 和朋友分享想法
    最多200字,当前共 发送

    已发送

    朋友将在看一看看到

    确定
    分享你的想法...
    取消

    分享想法到看一看

    确定
    最多200字,当前共

    发送中

    网络异常,请稍后重试

    微信扫一扫
    关注该公众号