Zināšanu bāze

List<T>.ConvertAll ()

Turpinot tēmu par sarakstiem un Generic iespējam, dažreiz ar minimālām koda rindiņām var uzrakstīt tipu pārveidošanas. Kā piemēru piedāvāju klasi darbam ar tagiem (tags - atslēgvārds, kuru pievieno rakstiem, lai to var grupēt)

Kods:


using
System;
using System.Collections.Generic;

namespace Samples
{
/// <summary>
///
Tag class
///
</summary>
public class
Tag
{

private readonly string text;

/// <summary>
/// Initializes a new instance of the <see cref="Tag"/>
class.
///
</summary>
/// <param name="text">The text.
</param>
protected Tag (string text)

{
this.text = text;

}

/// <summary>
///
Gets the text.
///
</summary>
/// <value>The text.
</value>
public string Text

{
get
{
return text;

}

}

/// <summary>
///
Gets the tags.
///
</summary>
/// <param name="text">The text.
</param>
///
<returns></returns>
public static IEnumerable<Tag> ReadString (string text)

{
List<string> list = new List<string> (text.Split (';'));
return list.ConvertAll (new Converter<string, Tag> (CreateInstance));

}

private static Tag CreateInstance (string substring)

{
return new Tag (substring.Trim ());

}

/// <summary>
///
Stores the specified list.
///
</summary>
/// <param name="list">The list.
</param>
public static void Store (IEnumerable<Tag> list)

{

// saglabā tagus
// ...

}

}

}

 

Izsaukums:

...


public static void Main (string
[] args)
{
string tags = ".NET2.0;Collections;Generic";

IEnumerable<Tag> list = Tag.ReadString (tags);

foreach (Tag tag in list)
{
Console.WriteLine (tag.Text);

}

Tag.Store (list);

Console.ReadLine ();

}

...


Posted Oct 04 2007, 05:20 PM by andrejs.mamontovs
Filed under:

Comments

google+ circles wrote re: List<T>.ConvertAll ()
on 03-24-2012 4:44

OQHZvx I cannot thank you enough for the blog post.Really looking forward to read more. Great.

Motivation to lose weight wrote re: List<T>.ConvertAll ()
on 04-09-2012 5:46

sDZvAQ This is one awesome blog. Keep writing.

seo wrote re: List<T>.ConvertAll ()
on 05-14-2012 23:31

O0jQSw Very informative blog article. Want more.

Cheap Seo Services wrote re: List<T>.ConvertAll ()
on 08-08-2012 6:28

P1IVfg Really informative article. Great.

crork wrote re: List<T>.ConvertAll ()
on 09-10-2012 0:28

efbfcP I value the post.Really thank you! Keep writing.

bookmarking submission wrote re: List<T>.ConvertAll ()
on 09-25-2012 7:02

X6cuKr I loved your article post.Much thanks again. Much obliged.

cheap bookmarking service wrote re: List<T>.ConvertAll ()
on 10-09-2012 1:54

Nlu6kv A big thank you for your blog.Much thanks again. Much obliged.

cheap bookmarking service wrote re: List<T>.ConvertAll ()
on 10-28-2012 2:33

altqaw Thanks for sharing, this is a fantastic article post.Really looking forward to read more. Much obliged.

cheap seo services wrote re: List<T>.ConvertAll ()
on 11-07-2012 15:18

Aw8OAr Great, thanks for sharing this blog article. Great.

Fiverr best selles wrote re: List<T>.ConvertAll ()
on 11-27-2012 23:20

yfseYz I value the blog post.Really looking forward to read more.

buy viagra online wrote re: List<T>.ConvertAll ()
on 12-23-2012 21:45

EO38KW Enjoyed every bit of your article post.Really thank you! Want more.

destockchine wrote re: List<T>.ConvertAll ()
on 01-10-2013 21:16

Absolutely adore, relationship, prise, tend not to unify citizens as much as a commonly used hate to get an issue.

destockchine www.destockchinefr.fr/.../veste-ed-hardy-pas-cher

manual social bookmarking service wrote re: List<T>.ConvertAll ()
on 01-18-2013 2:18

C820MX Im thankful for the blog post.Thanks Again. Great.

buy viagra wrote re: List<T>.ConvertAll ()
on 02-02-2013 20:51

kyOFxb A big thank you for your blog article.Really thank you! Will read on...

buy stendra online wrote re: List<T>.ConvertAll ()
on 02-24-2013 11:48

j8SFMq Appreciate you sharing, great post.Really looking forward to read more. Cool.

archeage gold wrote re: List<T>.ConvertAll ()
on 02-27-2013 2:22

Pretty section of content. I just stumbled upon your site and in accession capital to assert that I acquire in fact enjoyed account your blog posts. Anyway I will be subscribing to your feeds and even I achievement you access consistently rapidly. archeage gold www.cheap-archeage-gold.com

Finishline Coupons wrote re: List<T>.ConvertAll ()
on 03-04-2013 19:13

When there does exist spousal relationship not including adore, there will be adore not including spousal relationship. Finishline Coupons www.jordanretro10air.com

jordan 3 wrote re: List<T>.ConvertAll ()
on 03-06-2013 8:04

If you'd prefer a fantastic marketing on your valued at, count up everyone. jordan 3 http://www.nike44.com/

casquette unkut wrote re: List<T>.ConvertAll ()
on 03-06-2013 12:22

The main the worst strategy fail to see anybody thought of as working precise they always the group learning you are‘capital t have them. casquette unkut http://www.b66.fr/

destockchine wrote re: List<T>.ConvertAll ()
on 03-15-2013 0:04

I'd guess that Deity would love everyone based on a few incorrectly families ahead of when achieving the right choice, making sure that at which we once and for all meet the man, in the following pararaphs can remain gracious. destockchine http://www.c55.fr/

pari street wrote re: List<T>.ConvertAll ()
on 03-15-2013 7:10

Don憑t|capital t|big t|to|testosterone levels|testosterone|w not|longer|l|r|g|s|h|d|p|T|metric ton|MT|tonne} rubbish the effort at a people/lovely lady,individuals who isn憑t|capital t|big t|to|testosterone levels|testosterone|w not|longer|l|r|g|s|h|d|p|T|metric ton|MT|tonne} ready rubbish their very own day with you. pari street http://www.a88.fr/

destock mode wrote re: List<T>.ConvertAll ()
on 03-17-2013 2:47

Take pleasure in happens to be frail on begin, however it gets larger more powerful as they age exhibit your hard work accordingly provided with. destock mode http://www.b77.fr/

Carlie wrote re: List<T>.ConvertAll ()
on 03-18-2013 0:48

This inorfmaiton is off the hizool!

Gov Backlinks wrote re: List<T>.ConvertAll ()
on 03-20-2013 12:27

Thanks for the blog post.Really looking forward to read more. Much obliged.

Destockage vetement wrote re: List<T>.ConvertAll ()
on 03-21-2013 12:50

Laughter rrs really a essence you simply can't rain cats and dogs along a number of people without need of buying a few drops along your. Destockage vetement www.ruenike.com/chaussure-femme-c-4.html

Social bookmarks wrote re: List<T>.ConvertAll ()
on 03-23-2013 13:26

uwnKoG I truly appreciate this article post. Really Cool.

footcenterfr.fr wrote re: List<T>.ConvertAll ()
on 04-05-2013 0:28

Don't look down on, even when you can be ridiculous, while you never know the person falling gets interested an individual's satisfaction. footcenterfr.fr http://www.footcenterfr.fr/

buy social bookmarks wrote re: List<T>.ConvertAll ()
on 04-20-2013 8:08

mH2XTx I value the article.Much thanks again. Will read on...

digital slr lenses wrote re: List<T>.ConvertAll ()
on 05-14-2013 20:19

KRIYIW Really appreciate you sharing this article.Thanks Again. Fantastic.

seo pack wrote re: List<T>.ConvertAll ()
on 05-19-2013 17:14

exnJA0 Thanks for sharing, this is a fantastic blog article.Really looking forward to read more. Really Great.

good seo wrote re: List<T>.ConvertAll ()
on 05-25-2013 21:32

bZbxM6 Thanks a lot for the article post.Thanks Again. Really Cool.

seo service wrote re: List<T>.ConvertAll ()
on 05-28-2013 10:35

iCJ1EP Thanks a lot for the blog post.

seo service wrote re: List<T>.ConvertAll ()
on 05-29-2013 10:26

5AU0VC I am so grateful for your article.Really looking forward to read more. Want more.

christianlouboutinoutleta.com wrote re: List<T>.ConvertAll ()
on 06-03-2013 13:11

Go To THIS WebSite

social bookmarking service wrote re: List<T>.ConvertAll ()
on 06-06-2013 3:49

ahRrsE I value the article post. Great.

Snapback Hats Cheap wrote re: List<T>.ConvertAll ()
on 06-07-2013 5:57

Try These Guys

michael kors outlet wrote re: List<T>.ConvertAll ()
on 06-13-2013 12:50

You can try this out

michael kors wrote re: List<T>.ConvertAll ()
on 06-15-2013 15:55

good articles

Add a Comment

(obligāts)  
(brīvizvēles)
(obligāts)  
Remember Me?