OUR BLOG

Company News and Updates

Every week we share out expertise on effective strategies and technics to help you reach customers and prospects across the entire web.

Chapter97:FileandStreamI/O

Parameter                                                                Details path                The locationof thefile. append           Ifthefileexist,truewilladddatatotheendofthefile(append),falsewilloverwritethefile. text Text to be written or stored. contents       …
Learn More

Chapter96:Delegates

Section96.1:Declaringadelegatetype ThefollowingsyntaxcreatesadelegatetypewithnameNumberInOutDelegate,representingamethodwhichtakes an intand returns an int. publicdelegateintNumberInOutDelegate(intinput); Thiscanbeusedasfollows: publicstaticclassProgram { staticvoidMain() { NumberInOutDelegatesquare=MathDelegates.Square; intanswer1=square(4); Console.WriteLine(answer1);//Willoutput16…
Learn More

Chapter95:Attributes

Section95.1:Creatingacustomattribute //1)AllattributesshouldbeinheritedfromSystem.Attribute //2)Youcancustomizeyourattributeusage(e.g.placerestrictions)byusingSystem.AttributeUsage Attribute //3)Youcanusethisattributeonlyviareflectioninthewayitissupposedtobeused //4)MethodMetadataAttributeisjustaname.Youcanuseitwithout"Attribute"postfix-e.g. [MethodMetadata("Thistextcouldberetrievedviareflection")]. //5)Youcanoverloadanattributeconstructors [System.AttributeUsage(System.AttributeTargets.Method|System.AttributeTargets.Class)] publicclassMethodMetadataAttribute:System.Attribute { //thisiscustomfieldgivenjustforanexample //youcancreateattributewithoutanyfields //evenanemptyattributecanbeused-asmarker publicstringText{get;set;} //thisconstructorcouldbeusedas[MethodMetadata]…
Learn More

Chapter94:Structs

Section94.1:Declaringa struct publicstructVector { publicintX; publicintY; publicintZ; } publicstructPoint { publicdecimalx,y; publicPoint(decimalpointX,decimalpointY) { x=pointX; y=pointY; }…
Learn More

Chapter93:Preprocessordirectives

Section93.1:ConditionalExpressions Whenthefollowingiscompiled,itwillreturnadifferentvaluedependingonwhichdirectivesaredefined. //Compilewith/d:Aor/d:Btoseethedifference stringSomeFunction() { #ifA return"A"; #elifB return"B"; #else return"C"; #endif } Conditionalexpressionsaretypicallyusedtologadditionalinformationfordebugbuilds. voidSomeFunc() {…
Learn More

Chapter92:BindingList

Section92.1:Additemtolist BindingList<string>listOfUIItems=newBindingList<string>(); listOfUIItems.Add("Alice"); listOfUIItems.Add("Bob"); Section92.2:AvoidingN*2iteration ThisisplacedinaWindowsFormseventhandler varnameList=newBindingList<string>(); ComboBox1.DataSource=nameList;for(longi=0; i<10000;i++){ nameList.AddRange(new[]{"Alice","Bob","Carol"}); } Thistakesalongtimetoexecute,tofix,dothebelow: varnameList=newBindingList<string>(); ComboBox1.DataSource=nameList; nameList.RaiseListChangedEvents=false; for(longi=0;i<10000;i++){…
Learn More

Get new blog posts by email: