how to assign member variable to propertieshttp://forums.asp.net/t/1797590.aspx/1?how+to+assign+member+variable+to+propertiesFri, 27 Apr 2012 07:32:39 -040017975904954267http://forums.asp.net/p/1797590/4954267.aspx/1?how+to+assign+member+variable+to+propertieshow to assign member variable to properties <p>Hi</p> <p>I have an &nbsp;member variable. i want to assign the variable to properties.&nbsp;</p> <p>my work is the end user enter the value &nbsp;that value is assign the member variable that member variable ia assign to properties with using of class. can any one give me a sample code?</p> 2012-04-27T06:56:09-04:004954271http://forums.asp.net/p/1797590/4954271.aspx/1?Re+how+to+assign+member+variable+to+propertiesRe: how to assign member variable to properties <p>propertyName = memberVariableName;</p> <p>If this is not what you want can you show us the code that you have so far and where you are stuck?</p> 2012-04-27T06:57:38-04:004954279http://forums.asp.net/p/1797590/4954279.aspx/1?Re+how+to+assign+member+variable+to+propertiesRe: how to assign member variable to properties <p>hi,</p> <p>here is the sample for customerid</p> <p>&nbsp;</p> <p>&nbsp;Private StrCustomerId As String = &quot;&quot; &nbsp;&nbsp;&nbsp;</p> <p>Public Property CustomerId() As String &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</p> <p>&nbsp;Get &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</p> <p>&nbsp;&nbsp;&nbsp; Return StrCustomerId &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</p> <p>&nbsp;End Get &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</p> <p>&nbsp; Set(ByVal _CustomerId As String) &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</p> <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; StrCustomerId = _CustomerId &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</p> <p>&nbsp;&nbsp; End Set &nbsp;</p> <p>&nbsp;&nbsp; End Property</p> <p>&nbsp;</p> <p>&nbsp;</p> <p><strong>assign it to property like this</strong></p> <p>CustomerId= memebervariable</p> <p></p> 2012-04-27T07:03:18-04:004954287http://forums.asp.net/p/1797590/4954287.aspx/1?Re+how+to+assign+member+variable+to+propertiesRe: how to assign member variable to properties <p>tusharrs</p> <p>It might be best to stick to C# in your answers.&nbsp; Someone who asks a question this simple is unlikely to be able to do the VB to C# conversion.</p> 2012-04-27T07:07:36-04:004954331http://forums.asp.net/p/1797590/4954331.aspx/1?Re+how+to+assign+member+variable+to+propertiesRe: how to assign member variable to properties <p>I think C# Reflection will be the best solution to you...</p> <p>You should have possible member variables in your&nbsp; class...Then you can search for particular variable that user enters using Reflection and assign the value to it...</p> <p>var type = typeof(YourClass);<br> System.Reflection.PropertyInfo field = type.GetProperty(&quot;PropertyName&quot;, BindingFlags.Public<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; | BindingFlags.Instance<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; | BindingFlags.IgnoreCase);</p> <p>field.setValue(YourClassObject,Value,Null);</p> 2012-04-27T07:32:39-04:00