Click here to Skip to main content
15,883,805 members
Home / Discussions / C#
   

C#

 
GeneralMessageLoop... Pin
gekoscan22-Jan-03 21:31
gekoscan22-Jan-03 21:31 
GeneralRe: MessageLoop... Pin
Stephane Rodriguez.23-Jan-03 2:36
Stephane Rodriguez.23-Jan-03 2:36 
GeneralRe: MessageLoop... Pin
David Stone23-Jan-03 7:02
sitebuilderDavid Stone23-Jan-03 7:02 
QuestionProperties and objects (question about speed)? Pin
jinz22-Jan-03 20:44
jinz22-Jan-03 20:44 
AnswerRe: Properties and objects (question about speed)? Pin
Daniel Turini23-Jan-03 1:13
Daniel Turini23-Jan-03 1:13 
QuestionSSH From C# classes? Pin
cwkingjr22-Jan-03 17:57
cwkingjr22-Jan-03 17:57 
AnswerRe: SSH From C# classes? Pin
David Stone22-Jan-03 18:33
sitebuilderDavid Stone22-Jan-03 18:33 
GeneralC# arrays Pin
Nick Blumhardt22-Jan-03 17:26
Nick Blumhardt22-Jan-03 17:26 
Ok, something worries me about array types in C#. Two things actually, the first being the concrete type of an array of C# objects. The following:

SomeClass[] myArr = new SomeClass[10];

creates an object myArr that is of a type derived from System.Array, and specialised for objects of type SomeClass. My first question regards the [] operator. Where does it suddenly spring into the picture? It doesn't exist on objects of type System.Array. The type of the indexer for myArr above is SomeClass it seems, as the compiler won't let me make a statement like:

myArr[0] = new string;

and quite rightly so, complaining that string cannot be converted into SomeClass. Thus the indexer must be part of the interface of the automatically generated derived array type. The wierdness begins when I do this:

object[] mySameArr = myArr;
Console.Write (mySameArr[0]);

Now, this compiles and runs without a problem. How? The interfaces of the derived object[] and SomeClass[] types must be different, because each declares an indexer with a different signature. This probably shouldn't compile, or at least, shouldn't run, because despite SomeClass being derived from object, SomeClass[] is NOT derived from object[]! What's going on? Does the C# compiler fudge this some way, or does the .NET CTS have different relationships between array types that doesn't fit my (somewhat C++ skewed) view? Is this some kind of mock-up of generics that seems like it will be broken once real generics are implemented?

My second, and maybe not so confusing, question regards pointers and arrays. This appears in MSDN:

public unsafe int Read(byte[] buffer, int index, int count) 
{
   int n = 0;
   fixed (byte* p = buffer) 
   {
      ReadFile(handle, p + index, count, &n, 0);
   }
   return n;
}

Can anyone tell me where the conversion is made between the byte[] specialisation of System.Array and byte*? Is there a conversion operator defined in that subclass, or is there some other compiler funk going on?

Should I be poring through the C# standard? Thanks for any help, and please, if this has come up before (as I'm sure it would have) point me towards the old posting.
GeneralRe: C# arrays Pin
Nick Blumhardt22-Jan-03 20:36
Nick Blumhardt22-Jan-03 20:36 
GeneralWMI and C# Pin
Bo Hunter22-Jan-03 14:29
Bo Hunter22-Jan-03 14:29 
GeneralRe: WMI and C# Pin
David Stone22-Jan-03 18:38
sitebuilderDavid Stone22-Jan-03 18:38 
GeneralRe: WMI and C# Pin
thematt23-Jan-03 11:02
thematt23-Jan-03 11:02 
GeneralGetting current assembly path Pin
Luis Alonso Ramos22-Jan-03 9:12
Luis Alonso Ramos22-Jan-03 9:12 
GeneralRe: Getting current assembly path Pin
David Stone22-Jan-03 9:36
sitebuilderDavid Stone22-Jan-03 9:36 
GeneralRe: Getting current assembly path Pin
Luis Alonso Ramos22-Jan-03 9:57
Luis Alonso Ramos22-Jan-03 9:57 
GeneralSystems Analysis and Design Pin
Jassim Rahma22-Jan-03 6:38
Jassim Rahma22-Jan-03 6:38 
GeneralRe: Systems Analysis and Design Pin
SimonS24-Jan-03 0:48
SimonS24-Jan-03 0:48 
GeneralDrawText : what is similer with Win32SDK - DT_CENTER Pin
Wizard_@22-Jan-03 6:23
sussWizard_@22-Jan-03 6:23 
GeneralDB2 Connection using C# Pin
Jassim Rahma22-Jan-03 4:01
Jassim Rahma22-Jan-03 4:01 
GeneralRe: DB2 Connection using C# Pin
Vasudevan Deepak Kumar23-Jan-03 1:01
Vasudevan Deepak Kumar23-Jan-03 1:01 
GeneralRe: DB2 Connection using C# Pin
Jassim Rahma23-Jan-03 6:20
Jassim Rahma23-Jan-03 6:20 
GeneralRe: DB2 Connection using C# Pin
Vasudevan Deepak Kumar23-Jan-03 19:05
Vasudevan Deepak Kumar23-Jan-03 19:05 
GeneralRe: DB2 Connection using C# Pin
Jassim Rahma24-Jan-03 2:01
Jassim Rahma24-Jan-03 2:01 
GeneralRe: DB2 Connection using C# Pin
Vasudevan Deepak Kumar24-Jan-03 3:30
Vasudevan Deepak Kumar24-Jan-03 3:30 
GeneralRe: DB2 Connection using C# Pin
Jassim Rahma27-Jan-03 9:03
Jassim Rahma27-Jan-03 9:03 

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.