很简单,求把以下C#.net代码转换为C++.net代码,不胜感激~

片段一:classListBoxItem{publicstringText{get;set;}publicobjectValue{get;set;}publicListB... 片段一: class ListBoxItem
{ public string Text { get; set; }
public object Value { get; set; }
public ListBoxItem(string text = "", object value = null)
{ this.Text = text;
this.Value = value; }
public override string ToString()
{
return this.Text;
}
}

片段二: private void timer1_Tick(object sender, EventArgs e)
{ foreach(object obj in listBox1.Items)
{
ListBoxItem item = (ListBoxItem)obj;
if (DateTime.Now.ToString("yyyy年M月d日H时m分") == item.Text.ToString())
{
timer1.Enabled = false;
MessageBox.Show(item.Value.ToString());
timer1.Enabled = true;
}
}
}
展开
 我来答
冥盅米粒bl
2013-06-17 · TA获得超过569个赞
知道小有建树答主
回答量:559
采纳率:100%
帮助的人:239万
展开全部
//第一段 
using namespace System;
namespace Test {
 public ref class ListBoxItem
 {
 private:
  String^ _Text;
  Object^ _Value;
 public:
  property String^ Text
  {
   String^ get() { return  _Text ;}
   void set(String^ value) { _Text = value;}
  }
  property Object^ Value 
  { 
   Object^ get() { return _Value; } 
   void set(Object^ value){_Value = value;} 
  }            
 public: 
  ListBoxItem(String^ text , Object^ value)            
  {                
   this->Text = text;                
   this->Value = value;        
  }   
 public:
  virtual String^ ToString() override        
  {                
   return this->Text;
 };
}
更多追问追答
追问
您好,您能帮助我我非常感谢,可是我用您这段代码调试的时候有些问题呢~~还有麻烦能帮我改写下第二段吗?我遇到的问题就是:

“类 Form1 可以进行设计,但不是文件中的第一个类。Visual Studio
要求设计器使用文件中的第一个类。移动类代码使之成为文件中的第一个类,然后尝试重新加载设计器。”
由于我要把这个类放在可设计类前,因为可设计类要用到它,可是放在可设计类前后,就出现以上问题了~~
追答
private: System::Void timer1_Tick(System::Object^  sender, System::EventArgs^  e) {

     for each(Object^ obj in listBox1->Items)         
     {                
      ListBoxItem^ item = (ListBoxItem^)obj;               
      if (DateTime::Now.ToString("yyyy年M月d日H时m分") == item->Text)           
      { 
       timer1->Enabled = false;                
       MessageBox::Show(item->Value->ToString());           
       timer1->Enabled = true;           
      }       
     }
    }
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式