Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 805
  • Last Modified:

How to mask/limit string output in C#?


hello,

how can I set a length of string in an output?

I'm having a statement as sb.Append(String.Format("\"{0}\"", order.FullName)).Append(",");

However, I need to limit FullName field to 25 character and not more.

Thanks.
0
akohan
Asked:
akohan
1 Solution
 
Nash2334Commented:
string fullName = string.Empty;

if (order.FullName.Length > 24)
  fullName = order.FullName.Substring(0, 25);
else
  fullName = order.FullName;
0
 
akohanAuthor Commented:
Thanks
0
 
colly92002Commented:
string myLongString = "Big text long long big long text more than 25 characters BIIIIIIIGGGGGGGG";

string myFixedString = myLongString.Remove(25);
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now