Featured post

c# - Usage of Server Side Controls in MVC Frame work -

i using asp.net 4.0 , mvc 2.0 web application. project requiremrnt have use server side control in application not possibl in noraml case. ideally want use adrotator control , datalist control. i saw few samples , references in codepleax mvc controllib howwver found less useful. can tell how utilize theese controls in asp.net application along mvc. note: please provide functionalities related adrotator , datalist controls not equivalent functionalities thanks in advace. mvc pages not use normal .net solution makes use of normal .net components impossible. a normal .net page use event driven solution call different methods service side mvc use actions , view completly different way handle things. also, mvc not use viewstate normal .net controlls require. found article discussing mixing of normal .net , mvc.

visual studio 2010 - Compile error using C# automatically implemented properties -


a c# noob, trying use sharpdevelop utility convert vb.net application c#.

i noticing automatically implemented properties generating lot of errors. example, take following property:

public sqldatetime dateofbirth { get; set; }

whenever try access implied underlying module level variable, _dateofbirth, error.

error 699 name '_dateofbirth' not exist in current context d:\users\chad\desktop\besi csharp\besi\besi.businessobjects.convertedtoc#\chinavisa.cs 240 13 besi.businessobjects.converted

i expand properties declarations out full-fledged properties, should n't necessary , i'd understand why getting error.

you cannot access compiler-created backing variable - must use property. compiler-generated backing field named in such way prevent accessing (it not named _dateofbirth, named <dateofbirth>k__backingfield).

access property directly - if need manipulate backing field directly don't use automatically implemented property.

just side note - doesn't matter property name (it implementation detail , change on different versions of compiler or different compiler implementations altogether). field given identifier designed meet naming restrictions of clr fail naming restrictions of c# making impossible ever write straight c# code accesses variable directly.

also remember automatically implemented properties not public fields. shorthand compiler expands (sort of macro).

so class:

class bar {     public object foo { get; set; } } 

gets expanded this:

class bar {     [compilergenerated]     private object <foo>k__backingfield;      public object foo     {         [compilergenerated]                 {             return this.<foo>k__backingfield;         }         [compilergenerated]         set         {             this.<foo>k__backingfield = value;         }     } } 

it still full property - allowing compiler write getters , setters you.


Comments

Popular posts from this blog

c# - Usage of Server Side Controls in MVC Frame work -

cocoa - Nesting arrays into NSDictionary object (Objective-C) -

ios - Very simple iPhone App crashes on UILabel settext -