Click here to Skip to main content
15,916,463 members
Home / Discussions / C#
   

C#

 
GeneralHere's your "reply" Pin
leckey9-Jan-09 11:10
leckey9-Jan-09 11:10 
AnswerRe: running application Pin
#realJSOP9-Jan-09 11:02
professional#realJSOP9-Jan-09 11:02 
AnswerRe: running application Pin
DaveyM699-Jan-09 12:32
professionalDaveyM699-Jan-09 12:32 
Generalyou asked for it Pin
Luc Pattyn9-Jan-09 13:07
sitebuilderLuc Pattyn9-Jan-09 13:07 
QuestionText.Length Command Pin
asquaredtech9-Jan-09 8:51
asquaredtech9-Jan-09 8:51 
AnswerRe: Text.Length Command Pin
JByrd20069-Jan-09 8:58
JByrd20069-Jan-09 8:58 
GeneralRe: Text.Length Command Pin
asquaredtech9-Jan-09 9:15
asquaredtech9-Jan-09 9:15 
GeneralRe: Text.Length Command Pin
Colin Angus Mackay9-Jan-09 10:19
Colin Angus Mackay9-Jan-09 10:19 
asquaredtech wrote:
When I run your code the length of message is reported as 18, not 20. If I put another "\r\n" at the end of the string and it is reported as 20 not 24. Ignoring all "\"s in the string.


It isn't ignoring the slashes. The slashes indicate the start of an escape sequence. The slashes are interpreted by the compiler as if to say this and the next character represent something other than what is displayed in the source code.

In other words, treat the "n" in "\n" as the new line character rather than as an "n".

"\t" is the representation of the tab character (singluar) becuase it is difficult to represent that in code.

"\r\n" represent the character pair carriage return and newline. Although you put four characters in the source code, there are only two character actually generated in the compiled output.

If you do actually need to represent a slash character in a string in your source code then use "\\".


asquaredtech wrote:
I need this so I know what position I am in the string so I can remove the previous string "Line 1 of 3" and replace it with the new string "Line 1 of 2". While keeping any text already in the console. I am sending thousands of lines so I can't append them into the console.


One thing you could do is this. If you are displaying this on the Console, use Console.Write and finish your string with "\r" which is a carriage return. Without the newline that normally comes with it, it will return you to the start of the current line. You then overwrite the text that already exists on that line.

Many console applications use this technique when displaying progress status.

* Developer Day Scotland 2 - Free community conference
* The Blog of Colin Angus Mackay


Vogon Building and Loan advise that your planet is at risk if you do not keep up repayments on any mortgage secured upon it. Please remember that the force of gravity can go up as well as down.

AnswerRe: Text.Length Command Pin
Eddy Vluggen9-Jan-09 9:13
professionalEddy Vluggen9-Jan-09 9:13 
GeneralRe: Text.Length Command Pin
asquaredtech9-Jan-09 9:18
asquaredtech9-Jan-09 9:18 
GeneralRe: Text.Length Command Pin
Guffa9-Jan-09 17:19
Guffa9-Jan-09 17:19 
GeneralRe: Text.Length Command Pin
asquaredtech9-Jan-09 19:05
asquaredtech9-Jan-09 19:05 
GeneralRe: Text.Length Command Pin
Guffa9-Jan-09 19:54
Guffa9-Jan-09 19:54 
GeneralRe: Text.Length Command Pin
Luc Pattyn9-Jan-09 9:31
sitebuilderLuc Pattyn9-Jan-09 9:31 
GeneralRe: Text.Length Command Pin
asquaredtech9-Jan-09 10:14
asquaredtech9-Jan-09 10:14 
GeneralRe: Text.Length Command Pin
Colin Angus Mackay9-Jan-09 10:24
Colin Angus Mackay9-Jan-09 10:24 
GeneralRe: Text.Length Command Pin
Luc Pattyn9-Jan-09 10:27
sitebuilderLuc Pattyn9-Jan-09 10:27 
AnswerRe: Text.Length Command Pin
Rutvik Dave9-Jan-09 10:32
professionalRutvik Dave9-Jan-09 10:32 
AnswerRe: Text.Length Command Pin
Henry Minute9-Jan-09 10:51
Henry Minute9-Jan-09 10:51 
GeneralRe: Text.Length Command Pin
Colin Angus Mackay9-Jan-09 11:04
Colin Angus Mackay9-Jan-09 11:04 
GeneralRe: Text.Length Command Pin
Henry Minute9-Jan-09 11:28
Henry Minute9-Jan-09 11:28 
GeneralRe: Text.Length Command Pin
asquaredtech9-Jan-09 19:24
asquaredtech9-Jan-09 19:24 
GeneralRe: Text.Length Command Pin
Henry Minute9-Jan-09 23:45
Henry Minute9-Jan-09 23:45 
GeneralRe: Text.Length Command Pin
Luc Pattyn9-Jan-09 11:35
sitebuilderLuc Pattyn9-Jan-09 11:35 
GeneralRe: Text.Length Command Pin
Henry Minute9-Jan-09 11:36
Henry Minute9-Jan-09 11:36 

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.