.net - adding : notation to C# for indexing into arrays -


I use to use IDL and matlab in college and now when I have been working for a few years now I miss: for signaling arrays in the index such as

  array [1: 5]  

which will return an array from 1 to 5 elements . Another example is:

  stringVar.Split (")". ToCharArray ()) [1: *]  

which will return an array of string skipping on the first element.

Has anyone seen a path to Shu-horn: this is a sign in C #?

I have seen it in some interpreted language and Pearl or Python, can not remember

I wonder if it should be done with some operator override Could?

This is not currently applicable in BCL. For example, here's a quick and dirty example (not fully printed).

Public Fixed IEnumerable & lt; T & gt; GetRange & lt; T & gt; (This is IEnumerable & lt; T & gt; calculable, string category) {var arr = range.Split (':'); Var start = int32.Parse (arr [0]); If (ARR [1] == "*") {Refundable. Skip (Start); } And {var end = int32.Parse (arr [1]); Calculation of return. Skip (start). Take (end-to-end); }}

Then you can

  strVar.GetRange ("1: *"); // Leave the first element left strVar.GetRange ("1: 5"); // Skip the next element Next 5  

Note : I'm not fully familiar with the Matlab syntax, so I'm not sure that I expect it to be good specs That it gets general idea in all.


Comments

Popular posts from this blog

c++ - Linux and clipboard -

What is expire header and how to achive them in ASP.NET and PHP? -

sql server - How can I determine which of my SQL 2005 statistics are unused? -