c# - Pushing Items into stack with LINQ -


How can I push the cracketic string into the generic stack? [string] [array] = new string [] {"Liza", "Anna", "Sandra", "Dia" String array "};

Stack Setup

  Public square stack & lt; T & gt; {Private Ent Indexing; & Lt; T & gt; List; Public stack () {List = New list & lt; T & gt; (); Index = -1; } Public Zero Push (T-OBJ) {list.Add (obj); Index ++; } ...........}  

What changes do I need to make here?

  pile & lt; String & gt; Slist = new stack & lt; String & gt; (); Var v = Vals in array selection (P = & gt; slist.Push (p));  Error Report:   
 The type of expression in the selected section is incorrect.   

LINQ is a query language / framework, rather than a query (selection) you want to display here Amendment for the collection object - it is definitely designed for not LINQ (or also capable).

What you would like to do, however, is to define an extension method that can be found in the stack & lt; T & gt; for the class, however note that this is done in BCL stack & lt; T & gt; To understand the type, also here is the list & lt; T & gt; Instead of modifying the wheel again by using , what do you want Pushrange in the public stage & lt; T & gt; (This stack & lt; T & gt; source, IEnumerable & lt; T & gt; collection) {foreach (various items in the collection) source. Push (item); }

You can then allow the following to be done:

  myStack.PushRange (myCollection);  

And if you are not already convinced, then another philosophical reason: LINQ functional criteria was created to bring C # / .net, and the main part of functional programming Has a side effect free code. The combination of LINQ with state-modulated code would be quite incompatible in this way.


Comments

Popular posts from this blog

MySql variables and php -

url rewriting - How to implement the returnurl like SO in PHP? -

kernel - How to create a "Block device" in Windows -