Initializing an array of a certain type using another array (C#) -


This is my question: Suppose I have a class with such a manufacturer:

  Class A {Private Eye Eye; Public A (Int NII) {i = new_i; }}   

Can I initialize an array of A with an array of int? If so, how can I do this? I was thinking something like this:

  int [] b = new int [5] (0,1,2,3,4}; a [] a; a = new a [] (B);   

Thanks!

  var A = All Convert All (B, Item => New A (Item));   

The advantage here is that it will be created with the right size without any intermediate steps - Plus it works without LINQ.

This is a little bit of C # 2.0 - the following similar : :

  A [] a = array.Convert all & lt; int, a & gt; (b, delegate (Int item) {new A (item);});   

var , the combination of lambdass, and the improvement in the general type of estimation actually comes from C # 3.0 Is shining for.

Comments

Popular posts from this blog

qt - switch/case statement in C++ with a QString type -

python - sqlite3.OperationalError: near "REFERENCES": syntax error - foreign key creating -

Python's equivalent for Ruby's define_method? -