property in C#

  • Thread starter Thread starter Simon
  • Start date Start date
S

Simon

Hi all,

What is the equivalent code of the following in C#?

**********************************************************

Public ReadOnly Property EditURL(ByVal strKeyName As
String, ByVal strKeyValue As String) As String

Get
Return "~/EditModule.aspx?tabid=" &
TabId.ToString & "&mid=" & ModuleId.ToString & "&" &
strKeyName & "=" & strKeyValue
End Get

End Property

**********************************************************

Thank you

Simon
 
I'm not sure if there's a way to have properties that take parameters on a
class, unless the property is of a type that defines [,] as an operator
overload. Since this is readonly anyway, it may just be easier to use a
method, such as:

public string EditURL(string strKeyName, string strKeyValue)

{

return string.Format("~/EditModule.aspx?tabid={0}&mid={1}&{2}={3}",
TabId.ToString, ModuleId.ToString, strKeyName, strKeyValue);

}
 
I'm not sure if there's a way to have properties that take parameters on a
class, unless the property is of a type that defines [,] as an operator
overload. Since this is readonly anyway, it may just be easier to use a
method, such as:

public string EditURL(string strKeyName, string strKeyValue)

{

return string.Format("~/EditModule.aspx?tabid={0}&mid={1}&{2}={3}",
TabId.ToString, ModuleId.ToString, strKeyName, strKeyValue);

}
 
Oops--Ctrl+Enter because I tried to add a new line and paste at the same
time :-)

I'm not sure if there's a way to have properties that take parameters on a
class, unless the property is of a type that defines [,] as an operator
overload. Since this is readonly anyway, it may just be easier to use a
method, such as:
public string EditURL(string strKeyName, string strKeyValue)

{

return string.Format("~/EditModule.aspx?tabid={0}&mid={1}&{2}={3}",
TabId.ToString, ModuleId.ToString, strKeyName, strKeyValue);

}
 
Back
Top