Click here to Skip to main content
15,908,013 members

Welcome to the Lounge

   

For discussing anything related to a software developer's life but is not for programming questions. Got a programming question?

The Lounge is rated Safe For Work. If you're about to post something inappropriate for a shared office environment, then don't post it. No ads, no abuse, and no programming questions. Trolling, (political, climate, religious or whatever) will result in your account being removed.

 
GeneralRe: Fine, I'll jump on the "I hate Microsoft" bandwagon Pin
Mark_Wallace16-Jun-16 9:28
Mark_Wallace16-Jun-16 9:28 
GeneralRe: Fine, I'll jump on the "I hate Microsoft" bandwagon Pin
ZurdoDev16-Jun-16 9:33
professionalZurdoDev16-Jun-16 9:33 
GeneralRe: Fine, I'll jump on the "I hate Microsoft" bandwagon Pin
Mark_Wallace16-Jun-16 9:56
Mark_Wallace16-Jun-16 9:56 
GeneralRe: Fine, I'll jump on the "I hate Microsoft" bandwagon Pin
ZurdoDev16-Jun-16 10:01
professionalZurdoDev16-Jun-16 10:01 
GeneralRe: Fine, I'll jump on the "I hate Microsoft" bandwagon Pin
Mark_Wallace16-Jun-16 10:08
Mark_Wallace16-Jun-16 10:08 
GeneralRe: Fine, I'll jump on the "I hate Microsoft" bandwagon Pin
Deflinek16-Jun-16 9:43
Deflinek16-Jun-16 9:43 
GeneralRe: Fine, I'll jump on the "I hate Microsoft" bandwagon Pin
Mark_Wallace16-Jun-16 9:51
Mark_Wallace16-Jun-16 9:51 
GeneralRe: Fine, I'll jump on the "I hate Microsoft" bandwagon Pin
Richard Deeming16-Jun-16 11:36
mveRichard Deeming16-Jun-16 11:36 
No need to call Substring if the length is greater than (or equal to) the string's length.

And you'll get a NullReferenceException if the string is null, whereas VB would return an empty string instead. Seems like an odd choice, but when you're pandering to these VB devs... Roll eyes | :rolleyes:
C#
public static string Left(this string theString, int length)
{
    if (length < 0) throw new ArgumentOutOfRangeException(nameof(length));
    if (theString == null || length == 0) return string.Empty;
    if (theString.Length <= length) return theString;
    return theString.Substring(0, length);
}


Now, let's hope he doesn't ask for a C# version of this VB6 abomination:
VB
Dim s As String = "He11o"
Mid$(s, 3, 2) = "ll"




"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer


GeneralRe: Fine, I'll jump on the "I hate Microsoft" bandwagon Pin
Jono Stewart16-Jun-16 20:28
Jono Stewart16-Jun-16 20:28 
PraiseRe: Fine, I'll jump on the "I hate Microsoft" bandwagon Pin
Eddy Vluggen16-Jun-16 10:21
professionalEddy Vluggen16-Jun-16 10:21 
GeneralRe: Fine, I'll jump on the "I hate Microsoft" bandwagon Pin
glennPattonWork316-Jun-16 10:49
professionalglennPattonWork316-Jun-16 10:49 
NewsRe: Fine, I'll jump on the "I hate Microsoft" bandwagon Pin
Super Lloyd16-Jun-16 13:55
Super Lloyd16-Jun-16 13:55 
GeneralRe: Fine, I'll jump on the "I hate Microsoft" bandwagon Pin
Jono Stewart16-Jun-16 20:32
Jono Stewart16-Jun-16 20:32 
GeneralRe: Fine, I'll jump on the "I hate Microsoft" bandwagon Pin
Super Lloyd16-Jun-16 22:54
Super Lloyd16-Jun-16 22:54 
GeneralRe: Fine, I'll jump on the "I hate Microsoft" bandwagon Pin
den2k8816-Jun-16 23:15
professionalden2k8816-Jun-16 23:15 
GeneralRe: Fine, I'll jump on the "I hate Microsoft" bandwagon Pin
Super Lloyd16-Jun-16 23:31
Super Lloyd16-Jun-16 23:31 
GeneralRe: Fine, I'll jump on the "I hate Microsoft" bandwagon Pin
den2k8816-Jun-16 23:34
professionalden2k8816-Jun-16 23:34 
JokeRe: Fine, I'll jump on the "I hate Microsoft" bandwagon Pin
Super Lloyd17-Jun-16 6:39
Super Lloyd17-Jun-16 6:39 
GeneralRe: Fine, I'll jump on the "I hate Microsoft" bandwagon Pin
ZurdoDev17-Jun-16 1:18
professionalZurdoDev17-Jun-16 1:18 
GeneralRe: Fine, I'll jump on the "I hate Microsoft" bandwagon Pin
BillWoodruff16-Jun-16 14:41
professionalBillWoodruff16-Jun-16 14:41 
GeneralRe: Fine, I'll jump on the "I hate Microsoft" bandwagon Pin
Marc Clifton16-Jun-16 15:20
mvaMarc Clifton16-Jun-16 15:20 
GeneralRe: Fine, I'll jump on the "I hate Microsoft" bandwagon Pin
Sander Rossel16-Jun-16 21:10
professionalSander Rossel16-Jun-16 21:10 
GeneralRe: Fine, I'll jump on the "I hate Microsoft" bandwagon Pin
Member 1095214417-Jun-16 2:54
Member 1095214417-Jun-16 2:54 
GeneralRe: Fine, I'll jump on the "I hate Microsoft" bandwagon Pin
ZurdoDev17-Jun-16 2:57
professionalZurdoDev17-Jun-16 2:57 
GeneralRe: Fine, I'll jump on the "I hate Microsoft" bandwagon Pin
Member 1095214417-Jun-16 3:18
Member 1095214417-Jun-16 3:18 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.