-1

What does String* mean in C#?

I've seen this used in code examples but I can't derive from the context, and you can't search on this, due to the * being accepted as a wildcard in every search engine ever.


EDIT: Looks like it wasn't C#, which explains it. The specific code sample I'm looking at is extremely short (5 words) and I assumed it was mean to be C# from the context.

I was sure I'd seen it before, but my hazy memories were probably from other languages too.

Colin Pickard
  • 45,724
  • 13
  • 98
  • 148

3 Answers3

7

String*? Are you sure it's C#? You can't have pointers to reference types in C#. Unless String is a defined struct or something in that specific code...

Mehrdad Afshari
  • 414,610
  • 91
  • 852
  • 789
  • And not all value types. There's a concept called `unmanaged type` which consists of primitive types and value types containing only primitive types. – Mehrdad Afshari May 12 '09 at 10:00
  • That would explain it. The specific code sample I'm looking at is extremely short (5 words) and I assumed it was mean to be C# from the context, perhaps it's actually some other language, and the person that wrote it is actually getting confused (or trying to wind me up...). I'm sure I'd seen it before, but my hazy memories could actually be other languages too. – Colin Pickard May 12 '09 at 10:02
  • Indeed String* is very common in old managed C++ (not C++/CLI, in which it's replaced by String^). – Mehrdad Afshari May 12 '09 at 10:03
  • @Mehrdad: Yeah, specifically unmanaged types. Also note tha 'unmanaged type' is not a strict subset of primitive types, since string is in fact a primitive type, being supported directly by the compiler. (See http://msdn.microsoft.com/en-us/magazine/bb984984.aspx) – Noldorin May 12 '09 at 10:07
  • To be correct, C# *spec* does not define anything as primitive type. It just says value type and reference type: http://msdn.microsoft.com/en-us/library/aa691139(VS.71).aspx Primitive type is mostly a Java term, but essentially, that's the whole idea. – Mehrdad Afshari May 12 '09 at 10:11
  • No, but since you were using the term, I thought it would be appropiate to clarify. :) That is an MSDN source, after all, and I don't think you can debate it! – Noldorin May 12 '09 at 10:26
  • 1
    Noldorin: I don't want to debate on this (btw, I think you used the term first ;) ). Just on the MSDN is always right part: I've seen wrong or misleading points on MSDN *Library* several times (and I hardly call MSDN *magazine* an authority relative to the MSDN library). For instance: http://stackoverflow.com/questions/833946/in-c-will-the-finally-block-be-executed-in-a-try-catch-finally-if-an-unhandled/834017#834017 – Mehrdad Afshari May 12 '09 at 10:33
1

You sure you are not looking at Managed C++ examples?

leppie
  • 115,091
  • 17
  • 196
  • 297
0

You can use pointers in C# in unsafe code blocks, but I've only used them with value types or arrays of value types.

plinth
  • 48,267
  • 11
  • 78
  • 120