vc++.net 基本上保留了vc++的东西,但是在细节上也有了些差别,和c#的差别是非常大。下面是摸索的一个小小例子的一段代码。
从代码可以看出,声明所有引用类型的对象的时候,要有一个^
比如:System::String^ strA;

private:System::Voidbutton1_Click(System::Object^sender,System::EventArgs^e)...{
//System::String^a;
//a="liujincaiisagoodperson!";
//MessageBox::Show(a,"haoren",System::Windows::Forms::MessageBoxButtons::OK);
System::Collections::SortedList^b;
CrcDbConnection::CrcDbConnection^d=gcnewCrcDbConnection::CrcDbConnection();
d->ConnDatabase();
b=d->GetCodeSortList();
System::Text::StringBuilder^sb=gcnewSystem::Text::StringBuilder();
System::Int32i=0;
for(System::Int32j=0;j<b->Count;j++)
...{
sb->Append(System::Environment::NewLine);
sb->Append(b->GetByIndex(j));
}
MessageBox::Show(sb->ToString());
}
本文通过一个示例介绍了VC++.NET中对象声明的方式,并对比了其与C#的区别,重点在于如何声明引用类型对象,以及使用这些对象进行数据库操作。
590

被折叠的 条评论
为什么被折叠?



