c# 4.0 - dynamically set the propeties in c# -


i have following code in c#

class1 {  public string body         {  set             {                 byte[] bytestoencode = encoding.utf8.getbytes(value);                 string encodedtext = convert.tobase64string(bytestoencode);                 this._body = httputility.urlencode(encodedtext);             }         } } 

now inside class have provide string values body like

class class { class1 c = null; c.body = ??? } 

please me out how give values dynamically body . don't want hard code string literal.

regards priya

are perhaps trying initialize instance of class1, this?

class myclass {     private class1 c = new class1 { body = "foo" }; } 

or, maybe want create in myclass constructor:

public class myclass {     private class1 c;      public myclass(string body)     {         c = new class1 { body = body };     } } 

and create instance of myclass calling:

myclass mine = new myclass("foo"); 

if that's not you're trying do, need provide better second example, , description.


Comments