# C++ .NET String^



## Davidov541 (Apr 20, 2004)

I was trying to work through making a project in C++ .NET 2008 and the code I was looking off of from Microsoft used the notation String^. What does the carrot mean? I am including the entire code in here so you can see it, but it doesn't seem specific to Strings, but other than that, I can't find any mention of it anywhere. What does it mean and should I be worried about it?? Thanks!

// text_read.cpp
// compile with: /clr
#using<system.dll>
using namespace System;
using namespace System::IO;

int main()
{
String^ fileName = "textfile.txt";
try 
{
Console::WriteLine("trying to open file {0}...", fileName);
StreamReader^ din = File::OpenText(fileName);

String^ str;
int count = 0;
while ((str = din->ReadLine()) != nullptr) 
{
count++;
Console::WriteLine("line {0}: {1}", count, str );
}
}
catch (Exception^ e)
{
if (dynamic_cast<FileNotFoundException^>(e))
Console::WriteLine("file '{0}' not found", fileName);
else
Console::WriteLine("problem reading file '{0}'", fileName);
}

return 0;
}


----------



## artur02 (Sep 24, 2007)

> In C++/CLI the only type of pointer is the normal C++ pointer, and the .NET reference types are accessed through a "handle", with the new syntax ClassName^ instead of ClassName*. This new construct is especially helpful when managed and unmanaged code is mixed; it clarifies which objects are under .NET automatic garbage collection and which must be destroyed.


From http://en.wikipedia.org/wiki/C++/CLI


----------

