mystring.Substring(Math.Max(0, mystring.Length - 4)); //how many lines is this?
If you’re positive the length of your string is at least 4, then it’s even shorter:
mystring.Substring(mystring.Length - 4);
More Related Contents:
- What is the difference between String and string in C#?
- Why .NET String is immutable? [duplicate]
- Can I convert a C# string value to an escaped string literal?
- What is the difference between String and string in C#?
- String output: format or concat in C#?
- Differences in string compare methods in C#
- How can I split a string with a string delimiter? [duplicate]
- How do I write a backslash (\) in a string?
- How to replace multiple white spaces with one white space
- Evaluate string with math operators [duplicate]
- Splitting a string / number every Nth Character / Number?
- Convert JSON String to JSON Object c#
- Is String.Contains() faster than String.IndexOf()?
- Is there an alternative to string.Replace that is case-insensitive?
- How to replace part of string by position?
- Is String a primitive type?
- string.IsNullOrEmpty(string) vs. string.IsNullOrWhiteSpace(string)
- How to return text from Native (C++) code
- If strings are immutable in .NET, then why does Substring take O(n) time?
- string.ToLower() and string.ToLowerInvariant()
- @(at) sign in file path/string [duplicate]
- C# equivalent to Java’s charAt()?
- Instantiate a class from its textual name
- C# how convert large HEX string to binary
- Converting String To Float in C#
- Does String.GetHashCode consider the full string or only part of it?
- Detecting if a string is all CAPS
- Adding a newline into a string in C#
- Using StreamReader to check if a file contains a string
- How can I create all possible combinations for a set of words without repetition?