Click here to Skip to main content
15,895,011 members
Home / Discussions / C#
   

C#

 
GeneralRe: What do *you* use Rx for? Pin
Pete O'Hanlon20-Mar-15 5:38
mvePete O'Hanlon20-Mar-15 5:38 
QuestionAPLICATION Pin
Member 1153708318-Mar-15 15:57
Member 1153708318-Mar-15 15:57 
AnswerRe: APLICATION Pin
Dave Kreskowiak18-Mar-15 16:18
mveDave Kreskowiak18-Mar-15 16:18 
GeneralRe: APLICATION Pin
Pete O'Hanlon18-Mar-15 21:43
mvePete O'Hanlon18-Mar-15 21:43 
GeneralRe: APLICATION Pin
Dave Kreskowiak19-Mar-15 2:12
mveDave Kreskowiak19-Mar-15 2:12 
AnswerRe: APLICATION Pin
PIEBALDconsult18-Mar-15 17:13
mvePIEBALDconsult18-Mar-15 17:13 
Questionnew to c# - confused about substrings (Solved) Pin
Member 1153707618-Mar-15 15:51
Member 1153707618-Mar-15 15:51 
AnswerRe: new to c# - confused about substrings Pin
phil.o18-Mar-15 16:03
professionalphil.o18-Mar-15 16:03 
Indices in strings are zero-based.

So, when you write stw = st1.SubString(1, st1.Length - 1);, you get "/32" (this line compiles well for me, btw).

But, when you write stw = st1.SubString(2, 3);, you are trying to get 3 characters from st1 starting from "3", which obviously leads you towards the end of the string.

You may use String.Split() instead:
C#
string st1 = "1/32";
string[] parts = st1.Split(new char[] { '/' });
// parts[0] == "1";
// parts[1] == "32";

// You can then validate that you get valid integers
int numerator, denominator;
if (!int.TryParse(parts[0], out numerator)) {
   // There's a problem with the numerator
}
if (!int.TryParse(parts[1], out denominator)) {
   // There's a problem with the denominator
}

There are two kinds of people in the world: those who can extrapolate from incomplete data.

GeneralRe: new to c# - confused about substrings Pin
Member 1153707618-Mar-15 16:42
Member 1153707618-Mar-15 16:42 
GeneralRe: new to c# - confused about substrings Pin
phil.o18-Mar-15 17:06
professionalphil.o18-Mar-15 17:06 
QuestionDetect the last device connected to a serial port Pin
Member 1085025318-Mar-15 14:11
Member 1085025318-Mar-15 14:11 
AnswerRe: Detect the last device connected to a serial port Pin
Richard Andrew x6418-Mar-15 14:46
professionalRichard Andrew x6418-Mar-15 14:46 
QuestionMessage Removed Pin
18-Mar-15 9:04
professionalN_tro_P18-Mar-15 9:04 
AnswerRe: Geo location Pin
Richard Deeming18-Mar-15 10:13
mveRichard Deeming18-Mar-15 10:13 
QuestionLearning C# course Pin
Aindriu Mac Giolla Eoin18-Mar-15 8:23
Aindriu Mac Giolla Eoin18-Mar-15 8:23 
AnswerRe: Learning C# course Pin
Afzaal Ahmad Zeeshan18-Mar-15 11:06
professionalAfzaal Ahmad Zeeshan18-Mar-15 11:06 
GeneralRe: Learning C# course Pin
Aindriu Mac Giolla Eoin18-Mar-15 11:40
Aindriu Mac Giolla Eoin18-Mar-15 11:40 
GeneralRe: Learning C# course Pin
Afzaal Ahmad Zeeshan18-Mar-15 11:42
professionalAfzaal Ahmad Zeeshan18-Mar-15 11:42 
GeneralRe: Learning C# course Pin
Aindriu Mac Giolla Eoin18-Mar-15 12:02
Aindriu Mac Giolla Eoin18-Mar-15 12:02 
GeneralRe: Learning C# course Pin
Richard Givis24-Mar-15 10:48
Richard Givis24-Mar-15 10:48 
GeneralRe: Learning C# course Pin
Aindriu Mac Giolla Eoin24-Mar-15 11:55
Aindriu Mac Giolla Eoin24-Mar-15 11:55 
GeneralRe: Learning C# course Pin
Richard Givis24-Mar-15 11:58
Richard Givis24-Mar-15 11:58 
GeneralRe: Learning C# course Pin
Aindriu Mac Giolla Eoin19-Apr-15 8:26
Aindriu Mac Giolla Eoin19-Apr-15 8:26 
QuestionRe: Learning C# course Pin
Richard Givis20-Apr-15 3:44
Richard Givis20-Apr-15 3:44 
AnswerRe: Learning C# course Pin
Aindriu Mac Giolla Eoin20-Apr-15 6:57
Aindriu Mac Giolla Eoin20-Apr-15 6:57 

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.