Click here to Skip to main content
15,888,461 members
Home / Discussions / C#
   

C#

 
AnswerRe: Problem with IIF() Pin
Guffa21-Sep-06 23:48
Guffa21-Sep-06 23:48 
GeneralRe: Problem with IIF() Pin
J4amieC21-Sep-06 23:59
J4amieC21-Sep-06 23:59 
Questiontrim away last 4 characters of a string Pin
Support12321-Sep-06 21:23
Support12321-Sep-06 21:23 
AnswerRe: trim away last 4 characters of a string Pin
Stefan Troschuetz21-Sep-06 21:34
Stefan Troschuetz21-Sep-06 21:34 
GeneralRe: trim away last 4 characters of a string Pin
Support12321-Sep-06 21:46
Support12321-Sep-06 21:46 
GeneralRe: trim away last 4 characters of a string Pin
Stefan Troschuetz21-Sep-06 21:51
Stefan Troschuetz21-Sep-06 21:51 
GeneralRe: trim away last 4 characters of a string Pin
Support12321-Sep-06 21:53
Support12321-Sep-06 21:53 
AnswerRe: trim away last 4 characters of a string Pin
Guffa22-Sep-06 0:04
Guffa22-Sep-06 0:04 
NarutoFan#1 wrote:
would it work, if i use one of the examples someone gave me, to do it like this...

strName[strName.Length-1] = string.Empty;


Who gave you that example? That is not even close to something that would work.

The indexer property of a string returns a character, so the value of strName[strName.Length-1] is a character value. The property is read only (as strings can not be changed), so you can not give the character a new value. Even if you could, you would not be able to change the length of the string, and you would not be able to put in a string in place of the character.

As you can not change a string, the only way to get a string with a different contents is to create a new string that contains what you want. The SubString method (as suggested by Stefan) does this. The Remove method can also be used:

strName = strName.Remove(strName.Lenght - 4, 4);


---
b { font-weight: normal; }

GeneralRe: trim away last 4 characters of a string Pin
Support12322-Sep-06 0:17
Support12322-Sep-06 0:17 
GeneralRe: trim away last 4 characters of a string Pin
Guffa22-Sep-06 0:34
Guffa22-Sep-06 0:34 
GeneralRe: trim away last 4 characters of a string Pin
Support12322-Sep-06 0:42
Support12322-Sep-06 0:42 
GeneralRe: trim away last 4 characters of a string Pin
Support12322-Sep-06 0:20
Support12322-Sep-06 0:20 
Questioncheck boxes in C#.net 2005 Pin
Rohit Dev21-Sep-06 21:13
Rohit Dev21-Sep-06 21:13 
AnswerRe: check boxes in C#.net 2005 Pin
Guffa21-Sep-06 21:23
Guffa21-Sep-06 21:23 
AnswerRe: check boxes in C#.net 2005 Pin
Malcolm Smart21-Sep-06 21:38
Malcolm Smart21-Sep-06 21:38 
AnswerRe: check boxes in C#.net 2005 Pin
Christian Graus22-Sep-06 0:13
protectorChristian Graus22-Sep-06 0:13 
QuestionReading from a text Pin
cnr36921-Sep-06 21:06
cnr36921-Sep-06 21:06 
AnswerRe: Reading from a text Pin
Stefan Troschuetz21-Sep-06 21:42
Stefan Troschuetz21-Sep-06 21:42 
Questionhow to move form in a main form Pin
Parshant Verma21-Sep-06 20:58
Parshant Verma21-Sep-06 20:58 
AnswerRe: how to move form in a main form Pin
Nader Elshehabi21-Sep-06 21:55
Nader Elshehabi21-Sep-06 21:55 
QuestionRichEditCtrl Pin
shan2k21-Sep-06 20:11
shan2k21-Sep-06 20:11 
AnswerRe: RichEditCtrl Pin
Stefan Troschuetz21-Sep-06 21:46
Stefan Troschuetz21-Sep-06 21:46 
QuestionProblem set parameter value in Crystal report Pin
hieunts21-Sep-06 19:31
hieunts21-Sep-06 19:31 
QuestionReg: Webservies projects Pin
guru_41821-Sep-06 18:44
guru_41821-Sep-06 18:44 
AnswerRe: Reg: Webservies projects Pin
Christian Graus21-Sep-06 18:49
protectorChristian Graus21-Sep-06 18:49 

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.