Call String method inside another in C# and VB.Net

Last Reply one year ago By pandeyism

Posted one year ago

How to call string method to another method in C# ?

Posted one year ago


Please refer below sample.



protected void Page_Load(object sender, EventArgs e)
    string message = "Mudassar Khan";
    Response.Write("Length of <b> " + message + "</b> is : <b> " + GetLength(message) + "</b>");

public int GetLength(string name)
    return GetString(name).Length;

public string GetString(string strvalue)
    return strvalue;


Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
    Dim message As String = "Mudassar Khan"
    Response.Write("Length of <b> " & message & "</b> is : <b> " & GetLength(message) & "</b>")
End Sub

Public Function GetLength(ByVal name As String) As Integer
    Return GetString(name).Length
End Function

Public Function GetString(ByVal strvalue As String) As String
    Return strvalue
End Function


Length of Mudassar Khan is : 13