Link to home
Create AccountLog in
Avatar of NickMalloy
NickMalloyFlag for United States of America

asked on

Help converting code

I am a vb coder that is trying to convert to c#. I can't figure out this code.
Public Function Trunc(ByVal txt As String, ByVal pos As Integer) As String
        Do While txt.Substring(1, pos) <> Chr(32)
            pos -= 1
        Loop
        Return Left(txt, pos) & "..."
    End Function

Open in new window

Avatar of p_davis
p_davis

public string Trunc(string txt, int pos)
 {
     while (txt.Substring(1, pos) != Strings.Chr(32)) {
         pos -= 1;
     }
     return Strings.Left(txt, pos) + "...";
 }
the utility isn't perfect but it is a real good starting point.
Avatar of NickMalloy

ASKER

yeah  I used that before and can't get the code right. tried several utilites. It errors out say.

The name 'Strings' does not exist in the current context       
ASKER CERTIFIED SOLUTION
Avatar of p_davis
p_davis

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account