You must Sign In to post a response.
  • Category: .NET

    Hi to all how can write this below vb6 statement into c# language.

    VB6 STATEMENT: If Not (Right(LCase(Trim(rs.Fields("filename").Value)), 4) = ".mcr")
  • #587127
    if (String.Equals(Right(a.Trim().ToLower(), 4), ".mcr"))
    {
    // your code goes here...
    }

    static string Right(string s, int count)
    {
    string newString = String.Empty;
    if (s != null && count > 0)
    {
    int startIndex = s.Length - count;
    if (startIndex > 0)
    newString = s.Substring(startIndex, count);
    else
    newString = s;
    }
    return newString;
    }

  • #587151
    As said so many time, its better to make use of a Good code converter for all your code conversion issue of single line.


    if (!(rs.Fields("filename").Value.Trim().ToLower().Substring((rs.Fields("filename").Value.Trim().ToLower().Length - 4)) == ".mcr")) {

    }

    Thanks & Regards
    Anil Kumar Pandey
    Microsoft MVP, DNS MVM

  • #587211
    hey try this code



    if (!(Strings.Right(Strings.LCase(Strings.Trim(rs.Fields("filename").Value)), 4) == ".mcr"))

    {
    //your code
    }
    else
    {
    //your code
    }




    hope this will help you


  • This thread is locked for new responses. Please post your comments and questions as a separate thread.
    If required, refer to the URL of this page in your new post.