Language: C#
Object Initializer Syntax in C# 2008
//without using Object Initializer Syntax letter = new Letter(); letter.Date = DateTime.Now.Date; letter.RegisterDate = DateTime.Now.Date; letter.LetterType = LetterType.Outgoing; letter.LetterInformation = new LetterInformation(); letter.LetterInformation.RuntimeState = common.RuntimeState.Added; letter.LetterInformation.Letter = letter; letter.LetterInformation.Attachments = new ArrayList(); letter.LetterInformation.FileName = new LetterInformationMedia(); letter.LetterInformation.FileName.RuntimeState = common.RuntimeState.Added; letter.LetterInformation.FileName.LetterInformation = letter.LetterInformation; letter.LetterInformation.FileName.FileName = new common.FilePath(); letter.RelatedLetters = new ArrayList(); letter.AllLetterMedia = new ArrayList(); letter.RuntimeState = Faraconesh.ApplicationFramework.Common.RuntimeState.Added; //////////////////////////////////////////////////////////////////////////// //with using Object Initializer Syntax letter = new Letter() { Date = DateTime.Now.Date, RegisterDate = DateTime.Now.Date, LetterType = LetterType.Outgoing, Sec = OfficeAutomationUtility.GetCurrentSecretariat(), RelatedLetters = new ArrayList(), AllLetterMedia = new ArrayList(), RuntimeState = Faraconesh.ApplicationFramework.Common.RuntimeState.Added, LetterInformation = new LetterInformation() { RuntimeState = Faraconesh.ApplicationFramework.Common.RuntimeState.Added, //Letter = letter, Attachments = new ArrayList(), FileName = new LetterInformationMedia() { RuntimeState = Faraconesh.ApplicationFramework.Common.RuntimeState.Added, //LetterInformation = letter.LetterInformation, FileName = new Faraconesh.ApplicationFramework.Common.FilePath() } } }; //following lines can not be placed in the above initializer because of "Use of unassigned variable" error letter.LetterInformation.Letter = letter; letter.LetterInformation.FileName.LetterInformation = letter.LetterInformation;
Tags:
Description:
Object Initializer Syntax: one of interesting C# 2008 language features that bring C# into the family of functional languages.
Report Abuse
Subscribe
Discuss
What's new
What is it
New Snippet
Recent Snippets
My Snippets
Web Code
Search


see this: http://en.wikipedia.org/wiki/Functional_programming