womendu 发表于 2013-1-26 13:56:01

VC++.net 的第一个简单例子

vc++.net 基本上保留了vc++的东西,但是在细节上也有了些差别,和c#的差别是非常大。下面是摸索的一个小小例子的一段代码。
从代码可以看出,声明所有引用类型的对象的时候,要有一个^
比如:System::String^ strA;
<div style="padding-right: 5.4pt; padding-left: 5.4pt; background: #e6e6e6; padding-bottom: 4px; width: 95%; padding-top: 4px;">http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gifhttp://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gifprivate:System::Voidbutton1_Click(System::Object^sender,System::EventArgs^e)...{
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif//System::String^a;
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif//a="liujincaiisagoodperson!";
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif//MessageBox::Show(a,"haoren",System::Windows::Forms::MessageBoxButtons::OK);
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gifSystem::Collections::SortedList^b;
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gifCrcDbConnection::CrcDbConnection^d=gcnewCrcDbConnection::CrcDbConnection();
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gifd->ConnDatabase();
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gifb=d->GetCodeSortList();
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gifSystem::Text::StringBuilder^sb=gcnewSystem::Text::StringBuilder();
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gifSystem::Int32i=0;
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.giffor(System::Int32j=0;j<b->Count;j++)
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gifhttp://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif...{
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gifsb->Append(System::Environment::NewLine);
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gifsb->Append(b->GetByIndex(j));
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif}
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gifMessageBox::Show(sb->ToString());
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif}
页: [1]
查看完整版本: VC++.net 的第一个简单例子