声明&初始化数组? [英] declare & initialize array?

查看:79
本文介绍了声明&初始化数组?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,


我可以单独声明并初始化字符串数组吗?如何以及在哪里

我会在下面的代码中执行此操作?它是使用Visual C ++ 2005创建的

Express Beta 2 ...

在C#中我会有


private string [] myArray;


及更高版本


myArray = new string [] {" element 1"," element 2"现在,我知道C ++比C#更难学,但.......


谢谢


Geoff


#pragma一次


命名空间slider1

{

using namespace System;

using namespace System :: ComponentModel;

using namespace System :: Collections;

using namespace System :: Windows :: Forms;

使用命名空间System :: Data;

使用命名空间System :: Drawing;


public ref class Form1:public System :: Windows :: Forms :: Form

{


public:


Form1(无效)

{

InitializeComponent();

//

// TODO:添加构造函数代码她e $>
//


}


受保护:

///< ;摘要>

///清理正在使用的所有资源。

///< / summary>

///< param name =" disposing">"

参数的说明"< / param>

virtual void Dispose(布尔处理)覆盖

{

if(disposing&&组件)

{

删除组件;

}

__super :: Dispose(disposing);

}

private:System :: Windows :: Forms :: PictureBox ^ pictureBox1;

protected:

private:System :: Windows :: Forms :: Button ^ button1;

private:System :: Windows :: Forms :: Label ^ label1;

private:System :: Windows: :Forms :: Label ^ label2;

private:System :: Windows :: Forms :: TrackBar ^ trackBar1;

private:

/ //< summary>

///所需的设计变量。

///< / summary>

System :: ComponentModel: :Container ^ components;


#pragma region Windows窗体设计器生成的代码

///< summary>

// /支持Designer的必需方法 - 请不要使用代码编辑器修改

修改此方法的内容。

/// < / summary>

void InitializeComponent(void)

{


Syste m :: ComponentModel :: ComponentResourceManager ^ resources =(gcnew

System :: ComponentModel :: ComponentResourceManager(F orm1 :: typeid));

this-> pictureBox1 = (gcnew

系统:: Windows :: Forms :: PictureBox());

this-> button1 =(gcnew

系统: :Windows :: Forms :: Button());

this-> label1 =(gcnew

System :: Windows :: Forms :: Label());

this-> label2 =(gcnew

System :: Windows :: Forms :: Label());

this-> trackBar1 =(gcnew

System :: Windows :: Forms :: TrackBar());


(cli :: safe_cast< System :: ComponentModel :: ISupportInialialize ^

(this-> pictureBox1)) - > BeginInit();


(cli :: safe_cast< System :: ComponentModel :: ISupportIn itialize ^(this-> trackBar1)) - > BeginInit();
this-> SuspendLayout();

//

// pictureBox1

//

this-> pictureBox1-> Image =

(cli :: safe_cast< System :: Drawing :: Image ^(resources-> GetObject(L" pictureBox1.Image")));
this-> pictureBox1-> Location =

System :: Drawing :: Point(36,26);

this-> pictureBox1-> ; Name = L" pictureBox1";

this-> pictureBox1-> Size =

System :: Drawing :: Size(218,129);

this-> pictureBox1-> TabIndex = 0;

this-> pictureBox1-> TabStop = false;

//

// button1

//

this-> button1-> Location =

System :: Drawing ::点(105,231);

this-> button1-> Name = L" button1";

this-> button1-> Size =

系统::绘图::大小(75,23);

this-> button1-> TabIndex = 1;

this-> ; button1-> Text = L" button1";

//

// label1

//

this-> label1-> AutoSize = true;

this-> label1-> Location =

System :: Drawing :: Point(23,190 );

this-> label1-> Name = L" label1";

this-> label1-& gt;尺寸=系统::绘图::尺寸(31,

13);

this-> label1-> TabIndex = 2;

this-> label1-> Text = L" label1";

//

// label2

//

this-> label2-> AutoSize = true;

this-> label2-> Location =

System :: Drawing: :Point(222,190);

this-> label2-> Name = L" label2";

this-> label2-> Size = System ::绘图::尺寸(31,

13);

this-> label2-> TabIndex = 3;

this- > label2-> Text = L" label2";

//

// trackBar1

//

this-> trackBar1-> Location =

System :: Drawing :: Point(87,180);

this-> trackBar1-> Name = L" trackBar1";

this-> trackBar1->尺寸=

系统::绘图::尺寸(104,45);

this-> trackBar1-> TabIndex = 4;

this-> trackBar1-> Scroll + = gcnew

System :: EventHandl呃(这个& Form1 :: Form1_Load);

//

// Form1

//

this-> AutoScaleDimensions =

System :: Drawing :: SizeF(6,13);

this-> AutoScaleMode =

System :: Windows :: Forms :: AutoScaleMode :: Font;

this-> ClientSize = System :: Drawing :: Size(292,

266);

this-> Controls-> Add(this-> trackBar1);

this-> Controls-> Add(this-> label2);

this-> Controls-> Add(this-> label1);

this-> Controls-> Add(this-> button1);

this-> Controls-> Add(this-> pictureBox1);

this-> Name = L" Form1";

this-> Text = L" Form1";

this-> Load + = gcnew System :: EventHandler(this,

& Form1 :: Form1_Load) ;


(cli :: safe_cast< System :: ComponentModel :: ISupportIn itialize ^(this-> pictureBox1)) - > EndInit();


(cli :: safe_cast< System :: ComponentModel :: ISupportIn itialize ^(this-> trackBar1)) - > EndInit();



this-> ResumeLayout(false);

this-> PerformLayout();


}

#pragma endregion

private:System :: Void Form1_Load(System :: Object ^ sender,

System :: EventArgs ^ e){

}

};

}

解决方案

嗨Geoff!


声明数组如


private:System :: String __gc * myArray __gc [];


并在任何你想要的地方初始化它


this-> myArray = new System :: String * __gc [2];


this - > myArray [0] =" element 1";


this-> myArray [1] =" element 2";

Hope这有帮助!


- Markus

< Geoff Cox> schrieb im Newsbeitrag

新闻:bq ******************************** @ 4ax.com ...

您好,

我可以单独声明并初始化字符串数组吗?我将在下面的代码中如何以及在何处执行此操作?它是使用Visual C ++ 2005
Express Beta 2创建的......

在C#中我会有

private string [] myArray;

以后

myArray = new string [] {" element 1"," element 2"};

现在,我知道C ++更难学比C#还要.......

Geoff

#pragma一次

命名空间slider1 <使用命名空间System;
使用命名空间System :: ComponentModel;
使用命名空间System :: Collections;
使用命名空间System :: Windows :: Forms; 使用命名空间System :: Drawing;

public ref class Form1:public System :: Windows :: Forms :: Form
{<公开:

Form1(void)
{InitialifyComponent();
//
// TODO:添加构造函数代码在这里
//



受保护:
///< summary>
///清理所有资源正在使用。
///< / su mmary>
///< param name =" disposing">"
参数的说明"< / param>
virtual void Dispose(布尔处理)覆盖
{
if(disposing&&组件)
{
删除组件;
} __super :: Dispose(disposing);
}
private:System :: Windows :: Forms: :PictureBox ^ pictureBox1;
protected:
private:System :: Windows :: Forms :: Button ^ button1;
private:System :: Windows :: Forms :: Label ^ label1; <私有:System :: Windows :: Forms :: Label ^ label2;
private:System :: Windows :: Forms :: TrackBar ^ trackBar1;

private:
///< summary>
///所需的设计变量。
///< / summary>
System :: ComponentModel :: Container ^ components;

#pragma region Windows窗体设计器生成的代码
///< summary>
///设计器支持所需的方法 - 不要
修改
///使用代码编辑器的方法的内容。
///< / summary>
void InitializeComponent(void)


System :: ComponentModel :: ComponentResourceManager ^ resources =(gcnew
System :: ComponentModel :: ComponentResourceManager(F orm1 :: typeid));
this-> pictureBox1 =(gcnew
System :: Windows :: Forms :: PictureBox());
this-> button1 =(gcnew <系统:: Windows :: Forms :: Button());
this-> label1 =(gcnew
System :: Windows :: Forms :: Label());
this-> label2 =(gcnew
System :: Windows :: Forms :: Label());
this-> trackBar1 =(gcnew
System :: Windows :: Forms :: TrackBar());

(cli :: safe_cast< System :: ComponentModel :: ISupportIn itialize ^

(this-> pictureBox1)) - > BeginInit ();



(cli :: safe_cast< System :: ComponentModel :: ISupportIn itialize ^

(this-> trackBar1)) - > BeginInit ();


this-> SuspendLayout();
//
// pictureBox1
//
this-> pictureBox1-> Image =
(cli :: safe_cast< System :: Drawing :: Image ^

(resources-> GetObject(L" pictureBox1.Image")));


this-> pictureBo x1-> Location =
System :: Drawing :: Point(36,26);
this-> pictureBox1-> Name = L" pictureBox1";
this-> pictureBox1-> Size =
System :: Drawing :: Size(218,129);
this-> pictureBox1-> TabIndex = 0;
this-> pictureBox1-> ; TabStop = false;
//
// button1
//
this-> button1-> Location =
System :: Drawing :: Point( 105,231);
this-> button1-> Name = L" button1";
this-> button1-> Size =
System :: Drawing :: Size( 75,23);
this-> button1-> TabIndex = 1;
this-> button1-> Text = L" button1";
//
// label1
//
this-> label1-> AutoSize = true;
this-> label1-> Location =
System :: Drawing :: Point (23,190);
this-> label1-> Name = L" label1";
this-> label1-> Size = System :: Drawing :: Size(31,
13);
this-> label1-> TabIndex = 2;
this-> label1-> Text = L" label1";
//
// label2
//
this-> label2-> AutoSize = true;
this-> label2-> Location =
System :: Drawing :: Point(222,190);
this-> label2-> Name = L" label2";
this-> label2-> Size = System :: Drawing :: Size(31,
13);
this-> label2-> TabIndex = 3;
this-> label2-> Text = L" label2";
//
// trackBar1
//
this-> trackBar1-> Location =
System :: Drawing :: Point(87,180);
this-> trackBar1-> Name = L" trackBar1";
this-> trackBar1-> Size =
System :: Drawing :: Size(104,45);
this-> trackBar1-> TabIndex = 4;
this-> trackBar1-> Scroll + = gcnew
System :: EventHandler(this,& Form1 :: Form1_Load);
//
// Form1
//
this-> AutoScaleDimensions =
System :: Drawing :: SizeF(6,13);
this-> AutoScaleMode =
System :: Windows :: Forms :: AutoScaleMode :: Font;
this-> ClientSize = System :: Drawing ::大小(292,
266);
this-> Controls-> Add(this-> trackBar1);
this-> Controls-> Add(this-> label2);
this-> Controls-> Add(this-> label1);
this-> Controls-> Add(this-> button1);
this - > Controls-> Add(this-> pictureBox1);
this-> Name = L" Form1";
this-> Text = L" Form1";
this->加载+ = gcnew System :: EventHandler(this,
& Form1 :: Form1_Load);

(cli :: safe_cast< System :: ComponentModel :: ISupportIn itialize ^

(this-> pictureBox1)) - > EndInit();



(cli :: safe_cast< System :: ComponentModel :: ISupportIn itialize ^

(this-> trackBar1)) - > EndInit();


this-> ResumeLayout(false);
this-> PerformLayout( );

}
#pragma endregion
private:System :: Void Form1_Load(System :: Object ^ sender,
System :: EventArgs ^ e){
}
};
}



< Geoff Cox>在消息中写道

news:bq ******************************** @ 4ax.com ...

我可以单独声明并初始化字符串数组吗?我将在下面的代码中如何以及在何处执行此操作?它是使用Visual C ++ 2005
Express Beta 2创建的......

在C#中我会有

private string [] myArray;

以后

myArray = new string [] {" element 1"," element 2"};

现在,我知道C ++更难学比C#但.......




这是VC.Net 2003的等价物:


String * myArray [];


myArray = new String * [2];

myArray [0] = new String(" element 1");

myArray [1] = new String(" element 2");


我应该告诉你我没有在这个盒子上安装2005(其中我有两个C ++编译器限制< g>)但我认为要从MC ++转换为
C ++ / CLI所有你需要做的就是替换*'用^'和新'用'

gcnew'的


String ^ myArray [];


myArray = new String ^ [2];

myArray [0] = gcnew字符串(元素1);

myArray [1] = gcnew字符串("元素2");


问候,





几乎与C#一样:


数组< String ^> ; ^ myArray = gcnew array< String ^> {" element 1",

" element 2"};


您只能在Visual C ++ 2005中执行此操作,并且只能在.NET中执行此操作。这是一个全新的功能。


请参阅: http://www.codeproject.com/managedcpp/cppcliarrays.asp

在标准C ++和旧版MC ++中你无法初始化数组。 C ++没有
有阵列初始化的概念。


Tom


Geoff Cox写道:< blockquote class =post_quotes>你好,

我可以单独声明并初始化一个字符串数组吗?我将在下面的代码中如何以及在何处执行此操作?它是使用Visual C ++ 2005
Express Beta 2创建的......

在C#中我会有

private string [] myArray;

以后

myArray = new string [] {" element 1"," element 2"};

现在,我知道C ++更难学比C#但.......

谢谢Geoff



Hello,

Can I separately declare and initialize a string array? How and where
would I do it in the code below? It was created using Visual C++ 2005
Express Beta 2 ...

In C# I would have

private string[] myArray;

and later

myArray = new string[] {"element 1","element 2"};

Now, I know C++ is more difficult to learn than C# but .......

Thanks

Geoff

#pragma once

namespace slider1
{
using namespace System;
using namespace System::ComponentModel;
using namespace System::Collections;
using namespace System::Windows::Forms;
using namespace System::Data;
using namespace System::Drawing;

public ref class Form1 : public System::Windows::Forms::Form
{

public:

Form1(void)
{
InitializeComponent();
//
//TODO: Add the constructor code here
//

}

protected:
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">"description of the
parameter"</param>
virtual void Dispose(Boolean disposing) override
{
if (disposing && components)
{
delete components;
}
__super::Dispose(disposing);
}
private: System::Windows::Forms::PictureBox^ pictureBox1;
protected:
private: System::Windows::Forms::Button^ button1;
private: System::Windows::Forms::Label^ label1;
private: System::Windows::Forms::Label^ label2;
private: System::Windows::Forms::TrackBar^ trackBar1;
private:
/// <summary>
/// Required designer variable.
/// </summary>
System::ComponentModel::Container ^components;

#pragma region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not
modify
/// the contents of this method with the code editor.
/// </summary>
void InitializeComponent(void)
{

System::ComponentModel::ComponentResourceManager^ resources = (gcnew
System::ComponentModel::ComponentResourceManager(F orm1::typeid));
this->pictureBox1 = (gcnew
System::Windows::Forms::PictureBox());
this->button1 = (gcnew
System::Windows::Forms::Button());
this->label1 = (gcnew
System::Windows::Forms::Label());
this->label2 = (gcnew
System::Windows::Forms::Label());
this->trackBar1 = (gcnew
System::Windows::Forms::TrackBar());

(cli::safe_cast<System::ComponentModel::ISupportIn itialize^

(this->pictureBox1))->BeginInit();
(cli::safe_cast<System::ComponentModel::ISupportIn itialize^(this->trackBar1))->BeginInit(); this->SuspendLayout();
//
// pictureBox1
//
this->pictureBox1->Image =
(cli::safe_cast<System::Drawing::Image^(resources->GetObject(L"pictureBox1.Image"))); this->pictureBox1->Location =
System::Drawing::Point(36, 26);
this->pictureBox1->Name = L"pictureBox1";
this->pictureBox1->Size =
System::Drawing::Size(218, 129);
this->pictureBox1->TabIndex = 0;
this->pictureBox1->TabStop = false;
//
// button1
//
this->button1->Location =
System::Drawing::Point(105, 231);
this->button1->Name = L"button1";
this->button1->Size =
System::Drawing::Size(75, 23);
this->button1->TabIndex = 1;
this->button1->Text = L"button1";
//
// label1
//
this->label1->AutoSize = true;
this->label1->Location =
System::Drawing::Point(23, 190);
this->label1->Name = L"label1";
this->label1->Size = System::Drawing::Size(31,
13);
this->label1->TabIndex = 2;
this->label1->Text = L"label1";
//
// label2
//
this->label2->AutoSize = true;
this->label2->Location =
System::Drawing::Point(222, 190);
this->label2->Name = L"label2";
this->label2->Size = System::Drawing::Size(31,
13);
this->label2->TabIndex = 3;
this->label2->Text = L"label2";
//
// trackBar1
//
this->trackBar1->Location =
System::Drawing::Point(87, 180);
this->trackBar1->Name = L"trackBar1";
this->trackBar1->Size =
System::Drawing::Size(104, 45);
this->trackBar1->TabIndex = 4;
this->trackBar1->Scroll += gcnew
System::EventHandler(this, &Form1::Form1_Load);
//
// Form1
//
this->AutoScaleDimensions =
System::Drawing::SizeF(6, 13);
this->AutoScaleMode =
System::Windows::Forms::AutoScaleMode::Font;
this->ClientSize = System::Drawing::Size(292,
266);
this->Controls->Add(this->trackBar1);
this->Controls->Add(this->label2);
this->Controls->Add(this->label1);
this->Controls->Add(this->button1);
this->Controls->Add(this->pictureBox1);
this->Name = L"Form1";
this->Text = L"Form1";
this->Load += gcnew System::EventHandler(this,
&Form1::Form1_Load);

(cli::safe_cast<System::ComponentModel::ISupportIn itialize^(this->pictureBox1))->EndInit();
(cli::safe_cast<System::ComponentModel::ISupportIn itialize^(this->trackBar1))->EndInit();


this->ResumeLayout(false);
this->PerformLayout();

}
#pragma endregion
private: System::Void Form1_Load(System::Object^ sender,
System::EventArgs^ e) {
}
};
}

解决方案

Hi Geoff!

Declare the array like

private: System::String __gc* myArray __gc[];

and initialize it anywhere you want like

this->myArray = new System::String* __gc[2];

this->myArray[0] = "element 1";

this->myArray[1] = "element 2";
Hope that helps!

- Markus
<Geoff Cox> schrieb im Newsbeitrag
news:bq********************************@4ax.com...

Hello,

Can I separately declare and initialize a string array? How and where
would I do it in the code below? It was created using Visual C++ 2005
Express Beta 2 ...

In C# I would have

private string[] myArray;

and later

myArray = new string[] {"element 1","element 2"};

Now, I know C++ is more difficult to learn than C# but .......

Thanks

Geoff

#pragma once

namespace slider1
{
using namespace System;
using namespace System::ComponentModel;
using namespace System::Collections;
using namespace System::Windows::Forms;
using namespace System::Data;
using namespace System::Drawing;

public ref class Form1 : public System::Windows::Forms::Form
{

public:

Form1(void)
{
InitializeComponent();
//
//TODO: Add the constructor code here
//

}

protected:
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">"description of the
parameter"</param>
virtual void Dispose(Boolean disposing) override
{
if (disposing && components)
{
delete components;
}
__super::Dispose(disposing);
}
private: System::Windows::Forms::PictureBox^ pictureBox1;
protected:
private: System::Windows::Forms::Button^ button1;
private: System::Windows::Forms::Label^ label1;
private: System::Windows::Forms::Label^ label2;
private: System::Windows::Forms::TrackBar^ trackBar1;
private:
/// <summary>
/// Required designer variable.
/// </summary>
System::ComponentModel::Container ^components;

#pragma region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not
modify
/// the contents of this method with the code editor.
/// </summary>
void InitializeComponent(void)
{

System::ComponentModel::ComponentResourceManager^ resources = (gcnew
System::ComponentModel::ComponentResourceManager(F orm1::typeid));
this->pictureBox1 = (gcnew
System::Windows::Forms::PictureBox());
this->button1 = (gcnew
System::Windows::Forms::Button());
this->label1 = (gcnew
System::Windows::Forms::Label());
this->label2 = (gcnew
System::Windows::Forms::Label());
this->trackBar1 = (gcnew
System::Windows::Forms::TrackBar());

(cli::safe_cast<System::ComponentModel::ISupportIn itialize^

(this->pictureBox1))->BeginInit();



(cli::safe_cast<System::ComponentModel::ISupportIn itialize^

(this->trackBar1))->BeginInit();


this->SuspendLayout();
//
// pictureBox1
//
this->pictureBox1->Image =
(cli::safe_cast<System::Drawing::Image^

(resources->GetObject(L"pictureBox1.Image")));


this->pictureBox1->Location =
System::Drawing::Point(36, 26);
this->pictureBox1->Name = L"pictureBox1";
this->pictureBox1->Size =
System::Drawing::Size(218, 129);
this->pictureBox1->TabIndex = 0;
this->pictureBox1->TabStop = false;
//
// button1
//
this->button1->Location =
System::Drawing::Point(105, 231);
this->button1->Name = L"button1";
this->button1->Size =
System::Drawing::Size(75, 23);
this->button1->TabIndex = 1;
this->button1->Text = L"button1";
//
// label1
//
this->label1->AutoSize = true;
this->label1->Location =
System::Drawing::Point(23, 190);
this->label1->Name = L"label1";
this->label1->Size = System::Drawing::Size(31,
13);
this->label1->TabIndex = 2;
this->label1->Text = L"label1";
//
// label2
//
this->label2->AutoSize = true;
this->label2->Location =
System::Drawing::Point(222, 190);
this->label2->Name = L"label2";
this->label2->Size = System::Drawing::Size(31,
13);
this->label2->TabIndex = 3;
this->label2->Text = L"label2";
//
// trackBar1
//
this->trackBar1->Location =
System::Drawing::Point(87, 180);
this->trackBar1->Name = L"trackBar1";
this->trackBar1->Size =
System::Drawing::Size(104, 45);
this->trackBar1->TabIndex = 4;
this->trackBar1->Scroll += gcnew
System::EventHandler(this, &Form1::Form1_Load);
//
// Form1
//
this->AutoScaleDimensions =
System::Drawing::SizeF(6, 13);
this->AutoScaleMode =
System::Windows::Forms::AutoScaleMode::Font;
this->ClientSize = System::Drawing::Size(292,
266);
this->Controls->Add(this->trackBar1);
this->Controls->Add(this->label2);
this->Controls->Add(this->label1);
this->Controls->Add(this->button1);
this->Controls->Add(this->pictureBox1);
this->Name = L"Form1";
this->Text = L"Form1";
this->Load += gcnew System::EventHandler(this,
&Form1::Form1_Load);

(cli::safe_cast<System::ComponentModel::ISupportIn itialize^

(this->pictureBox1))->EndInit();



(cli::safe_cast<System::ComponentModel::ISupportIn itialize^

(this->trackBar1))->EndInit();


this->ResumeLayout(false);
this->PerformLayout();

}
#pragma endregion
private: System::Void Form1_Load(System::Object^ sender,
System::EventArgs^ e) {
}
};
}



<Geoff Cox> wrote in message
news:bq********************************@4ax.com...

Can I separately declare and initialize a string array? How and where
would I do it in the code below? It was created using Visual C++ 2005
Express Beta 2 ...

In C# I would have

private string[] myArray;

and later

myArray = new string[] {"element 1","element 2"};

Now, I know C++ is more difficult to learn than C# but .......



This is the VC.Net 2003 equivalent:

String *myArray[];

myArray = new String*[2];
myArray[0] = new String("element 1");
myArray[1] = new String("element 2");

I should tell you that I don''t have 2005 installed on this box (where I have
a two C++ compiler limit <g>) but I think that to convert from MC++ to
C++/CLI all you have to do is to replace the *''s with ^''s and new''s with
gcnew''s

String ^myArray[];

myArray = new String^ [2];
myArray[0] = gcnew String("element 1");
myArray[1] = gcnew String("element 2");

Regards,
Will



Almost like in C#:

array<String^>^ myArray = gcnew array<String^> {"element 1",
"element 2"};

You can only do this in Visual C++ 2005, and only in .NET. It''s a
completely new feature.

See: http://www.codeproject.com/managedcpp/cppcliarrays.asp

In standard C++ and old MC++ you can''t initialize arrays. C++ doesn''t
have the concept of array initialization.

Tom

Geoff Cox wrote:

Hello,

Can I separately declare and initialize a string array? How and where
would I do it in the code below? It was created using Visual C++ 2005
Express Beta 2 ...

In C# I would have

private string[] myArray;

and later

myArray = new string[] {"element 1","element 2"};

Now, I know C++ is more difficult to learn than C# but .......

Thanks

Geoff



这篇关于声明&amp;初始化数组?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆