中の技術日誌ブログ

C#とC++/CLIと
VBと.NETとWindowsで戯れる
 

目次

Blog 利用状況

ニュース

自己紹介

東京でソフトウェアエンジニアをやっています。
お仕事大募集中です。
記事執筆や、講師依頼とかでも何でもどうぞ(*^_^*)
似顔絵 MSMVPロゴ
MSMVP Visual C# Since 2004/04-2013/03

記事カテゴリ

書庫

日記カテゴリ

00-整理

01-MSMVP

C# 階層構造を持っているデータをフラットに取得したい場合

+1

+--2

   +--3

   +--4

+--5

こんなデータをforeachで1~5って取りたい場合ありますよね。

public static class SampleClass
{
	public abstract class IChildData
	{
		public List Children;
	}

	public static IEnumerable<IChildData> フラットに取得する(IEnumerable<IChildData> src)
	{
		foreach (var dataNode in src)
		{
			yield return dataNode;
			if (dataNode.Children != null)
			if (dataNode.Children.Count != 0)
			{
				foreach (var node in フラットに取得する(dataNode.Children))
				{
					yield return node;
				}
			}
		}
	}
}

循環参照しちゃってるとforeach終わらないので注意して下さいね。

投稿日時 : 2013年1月24日 10:15

コメントを追加

# vivienne westwood bags 2014/04/05 23:27 http://viviennewestwood.atlasrestaurant.co.uk/

9 eggs

# vivienne westwood sale 2014/04/07 11:25 http://viviennewestwood.designreports.co.uk/

This is the highest rating the first lady has received since April 2009. Mrs. Obama , on Sept. 4.

# vivienne westwood earrings 2014/04/09 18:42 http://viviennewestwood.atlasrestaurant.co.uk/

The SPF number indicates the amount of sun exposure needed to cause sunburn on sunscreen-protected skin compared with unprotected skin. For example, a SPF rating of 30 means it would take the person 30 times longer to burn wearing sunscreen than with exposed skin.

# vivienne westwood dresses 2014/04/11 6:54 http://viviennewestwooduk.penningtonmcgee.com/

and procedures of the agencies of crime control and criminal justice, Pirollo, But the team still siphons through the list on a monthly basis to make sure that it is 100-percent accurate. Prospective students are invited to learn more about our undergraduate and graduate programs through personal contact with faculty and students, “High Speed Automatic Blood Cell Counter and Cell Size Analyzer”. a New York stock exchange listed global provider of diagnostic systems and consumables. Colorado:Exam Matrix Publishing, C. at the inaugural Philadelphia Science Festival, Yudell donned a wig and the persona of Philadelphia physician and U.

# vivienne westwood sale 2014/04/11 20:49 http://viviennewestwood.designreports.co.uk/

Gen. Zelmia Oryakhail, provincial police chief of Paktia province, told CBS News' Mukhtar Ahmad the attacker targeted a joint U.S. military and Afghan Local Police (ALP) patrol. Oryakhail said the bomber on a motorcycle detonated his explosives in Samkani district as American forces passed. He said a local school had just let pupils, who were between 10 and 16 years old, out for the day.

# vivienne westwood dresses 2014/04/19 9:55 http://viviennewestwooduk.penningtonmcgee.com/

A from the House space subcommittee being debated right now would cancel the mission and steer the agency toward other projects. That bill will be discussed during a hearing Wednesday (June 19) at 10 a.m. EDT.

# nike free run homme 2014/04/19 10:05 http://www.chaussurefreerun.fr/nike-free-run-homme

Nike SB vient de concevoir un nouveau coloris de Nike SB Zoom Stefan Janoski qui affiche un dessus en daim blanc cass茅 contrast茅 par des accents de turquoise ? la &lsquo;Tiffany&rsquo;.

# nike free run 3 femme 2014/04/19 10:10 http://www.free-lancer.fr/Nike_Free_femme/nike_fre

Les Nike Air Royal sortiront ? New York, au Niketown NYC, le 22 juin ($120), les Nike Air Flytop ? San Francisco au Niketown Union Square le 22 juin ($140) et les Nike Lunar Flow au Nike Portland le 15 juin ($130).

# vivienne westwood shoes 2014/04/21 7:14 http://viviennewestwoodbags.lifestyle-people.com/

Ortiz embarked on her master’s in higher education at Drexel. “He never spoke about the work of the day but talked to me about my future. all of whom wanted Tiana to know that she and her hair are perfect just the way they are.“I’m calling on everyone to join me in ‘singing a Black girl’s song, a Witness from Boston, He was talking about the significance of Witnesses to Hunger,"The renowned architect Frank Lloyd Wright said that a buildings form and function should be one, each have a lab in the building that is equipped with the latest technology (not to mention some of the best views of University City).16 (Sep 2003):181-205 Ployhart, and Ziegert.

# Femmes Air Force One Low 2014/05/21 7:17 http://eyepathologist.com/nike-chaussures-fr.asp?P

Mark Borkowski, a public relations and branding expert, said the royal family has learned from their mistakes. "Clearly, from Diana onwards, they've had to change, reluctantly at times, but here they see the two brand ambassadors for the royal family and for Britain. They're young, they're fresh. They're Hollywood."

# JADE 2014/05/31 9:13 http://www.onlinecor.net/shoponline.asp?cheap=prod

▽1万円 タカハシカツコ▽1万円 タケダユウコ▽5千円 チバシヅコ▽5千円 ツノダカツミ

# Hogan Olympia Uomo 2014/06/10 6:45 http://www.interplanet-gsa.it/scarpeonlineit.asp?s

Education will only get you in the door. Early in the movie, the standout online interview seals the deal, rather than the pair's fake degrees from The University of Phoenix. Later on, the better-educated villain spends more time talking trash than working on his projects and doesn't get a job offer. Some internship and job-seekers lament the fact that they didn't get into, or couldn't afford to attend, a top-tier college, and therefore are at a disadvantage. While it's true that the name of a great school on your resume can get you in the door for an interview, the same can be said for a strong network, an , an eye-catching blog or a . And once you're in that door, your education is usually only as useful to your success as you make it.

# marimekko 2014/06/16 15:23 http://www.momentofluxury.com/jpshoponline.asp?che

Would you consider an internship? Why or why not? Please sign in below and share. And for more career advice, follow on Twitter.

# YPYSwVpPFbYWWD 2015/05/03 5:05 horny

tZOoNt http://www.FyLitCl7Pf7kjQdDUOLQOuaxTXbj5iNG.com

タイトル  
名前  
URL
コメント