Avatar of NickMalloy
NickMalloy
Flag 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

C#

Avatar of undefined
Last Comment
p_davis

8/22/2022 - Mon
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) + "...";
 }
p_davis

the utility isn't perfect but it is a real good starting point.
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck
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
p_davis

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.