Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 798
  • 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

Featured Post

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

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