Truncate string is used to show the specific part of the string. If you want to truncate the string then you have to specify that substring by giving the length. You have to specify the length of substring.
To understand this let us consider an example in which we will make a static class and then define a method which truncates the string. Then we will call that method in the main method and pass a string and length of substring because it takes 2 parameters. And it will return a substring of that size in which we pass to the method.
To demonstrate make console application and write the following code.
staticvoid Main(string args)
publicstaticstring Truncate(string source, int length)
if (source.Length> length)
source = source.Substring(0, length);
Truncate string in C# - CSharp