Click here to Skip to main content
15,889,874 members
Home / Discussions / C#
   

C#

 
AnswerRe: Avoiding Random() Class generate the same number Pin
PIEBALDconsult19-Aug-09 7:45
mvePIEBALDconsult19-Aug-09 7:45 
QuestionWhy \r\n? Pin
hairy_hats19-Aug-09 3:00
hairy_hats19-Aug-09 3:00 
AnswerRe: Why \r\n? Pin
Keith Barrow19-Aug-09 3:09
professionalKeith Barrow19-Aug-09 3:09 
GeneralRe: Why \r\n? Pin
hairy_hats19-Aug-09 3:14
hairy_hats19-Aug-09 3:14 
GeneralRe: Why \r\n? Pin
Eddy Vluggen19-Aug-09 3:21
professionalEddy Vluggen19-Aug-09 3:21 
GeneralRe: Why \r\n? Pin
hairy_hats19-Aug-09 3:47
hairy_hats19-Aug-09 3:47 
GeneralRe: Why \r\n? Pin
Dan Neely19-Aug-09 4:33
Dan Neely19-Aug-09 4:33 
AnswerRe: Why \r\n? Pin
PIEBALDconsult19-Aug-09 4:51
mvePIEBALDconsult19-Aug-09 4:51 
Text files generally contain several "lines" of text, separated by "linefeeds" (ASCII 10).

On some operating systems, the file will also contain "carriage returns" (ASCII 13).

The developers of the original C library decided that, for portability, the programmer shouldn't need to know the details.

So, in C you just specify '\n' and the operating system will add a '\r' if it chooses. Likewise, when reading a text file, if the file contains '\r\n', the '\r' will not be returned to the program.

And it was good.


But the designers of .net decided otherwise and think that the programmer should know the details, so we usually have to specify the '\r' or use System.Environment.NewLine which is supposed to aid portability (not that they expect .net to be ported), but which will do just the opposite in the end.

In theory, on a Windows system NewLine will equate to "\r\n" and on some other system it may be "\n" or "\r" or who knows what.
The problem, as I see it, is that this won't work on OpenVMS -- OpenVMS supports many types of files, including many types of text files.
On an OpenVMS system, you can have text files with "\r\n", "\n", or "\r" or with Fortran encoding, just about anything -- what will NewLine be set to on OpenVMS if .net gets ported to it? I suspect they will settle on "\n" and let the operating system figure it out -- just like in C.
AnswerRe: Why \r\n? Pin
Vikram A Punathambekar19-Aug-09 7:13
Vikram A Punathambekar19-Aug-09 7:13 
GeneralRe: Why \r\n? Pin
hairy_hats19-Aug-09 8:17
hairy_hats19-Aug-09 8:17 
GeneralRe: Why \r\n? Pin
PIEBALDconsult19-Aug-09 18:20
mvePIEBALDconsult19-Aug-09 18:20 
QuestionListBox - drag to organize Pin
transmitable19-Aug-09 2:55
transmitable19-Aug-09 2:55 
AnswerRe: ListBox - drag to organize Pin
Saksida Bojan19-Aug-09 6:24
Saksida Bojan19-Aug-09 6:24 
Questioncoloring the row after pressing a button Pin
salemmohamed19-Aug-09 2:23
salemmohamed19-Aug-09 2:23 
AnswerRe: coloring the row after pressing a button Pin
stancrm19-Aug-09 2:31
stancrm19-Aug-09 2:31 
QuestionAdd new component to visual studio 2008 Pin
tamir10119-Aug-09 1:58
tamir10119-Aug-09 1:58 
AnswerRe: Add new component to visual studio 2008 [modified] Pin
Hristo-Bojilov19-Aug-09 2:58
Hristo-Bojilov19-Aug-09 2:58 
Questionhow to change datagridview cell value color if datatable current value is changed Pin
Nitin K19-Aug-09 1:49
Nitin K19-Aug-09 1:49 
AnswerRe: how to change datagridview cell value color if datatable current value is changed Pin
stancrm19-Aug-09 2:32
stancrm19-Aug-09 2:32 
GeneralRe: how to change datagridview cell value color if datatable current value is changed Pin
Nitin K19-Aug-09 2:47
Nitin K19-Aug-09 2:47 
GeneralRe: how to change datagridview cell value color if datatable current value is changed Pin
stancrm19-Aug-09 3:12
stancrm19-Aug-09 3:12 
GeneralRe: how to change datagridview cell value color if datatable current value is changed Pin
Nitin K19-Aug-09 3:23
Nitin K19-Aug-09 3:23 
GeneralRe: how to change datagridview cell value color if datatable current value is changed Pin
stancrm19-Aug-09 3:36
stancrm19-Aug-09 3:36 
QuestionListview Flicker Pin
pseudonym6719-Aug-09 1:46
pseudonym6719-Aug-09 1:46 
AnswerRe: Listview Flicker Pin
Saksida Bojan19-Aug-09 6:07
Saksida Bojan19-Aug-09 6:07 

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.