Multilanguage ??? ?????? ??? ????? C# ???????? ???? ?? ??? ???? ????

???? ?????? ???? ??????
???? ID: 816175 - ?? ???????? ?? ?????? ??? ?? ?? ???? ???? ???? ??.
?? ???? ?? Microsoft Visual Basic .NET ??????? ?? ???, ?????317702.

?? ????? ???


??? ?? ??????? ???? | ??? ?? ??????? ????

?? ????? ??

??????

?? ???? ????? ???? ?? ?? multilanguage ??? ?????? ?? ????? ?? Visual C# .NET ?? Visual C# 2005 ?? ???????? ???? ?? ??? ???? ?????

???? ???????

??????????

????? ???? outlines ???????? ?????????, ??????????, ??????? ?????? ?? ?????? ??? ?? ???? ???:
  • ?? ????? ???????? ???????? ??? ??:
    • Microsoft Windows 2000 Professional (?? ?????)
    • .NET Framework ??????? ?? ??? Microsoft Windows XP Professional
    • Microsoft Windows Server 2003
  • Microsoft Visual Studio .NET ?? Microsoft Visual Studio 2005?
  • Microsoft SQL Server ??????? 7.0 ?? ??? ?? ????????? ????????
?? ???? ????? ?? ?? ?? ????? ???? ?? ?????? ???:
  • ??????????? ??????????
  • Windows ???????
  • ADO.NET
???? ???

??? Multilanguage ??? ?????? ???????? ????

?? ???? ????? ???? ?? ?? ????? ??? ??????????? ??? ?????? ????? ?? ??? ???? ????:
  • ????? C# Windows ????????? ???? ?? ????????? ???? ??? ??????? ?? ????? ???? ???
  • ???? Visual Basic .NET ?? Visual Basic 2005 ????????? ????????? ?? NorthWind ??????? ?? ??????? ?? ?? ?? DataSet ???? ???
  • ????? C# ????? ????????? ????????? ???? ?? ?? ???? ???? ?? ?? ????ArrayList???????? ?????????? ?? ???? ??? ?????? ???????? ???? concatenated ?? ??????? ?? ????? ??StringBuilder?????
??? ?? ?? ????? C# Windows ??????? ????? ?? ??? ????? ?????, ???? ?????? ?? ??? ?????????:
  1. ????? ????,????????? ????? ????,???????????, ?? ???? ??? ?? ?? ?? ????? ????Microsoft Visual Studio .NET(?? ??? Visual Studio .NET 2002),Microsoft Visual Studio .NET 2003(?? ??? Microsoft Visual Studio .NET 2003), ??Microsoft Visual Studio 2005(?? ??? Microsoft Visual Studio 2005)?
  2. ????? ????,Microsoft Visual Studio .NET??,Microsoft Visual Studio 2005.
  3. ????? ????,??? ??????????? ????-????? ????, ?? ???? ???????? C# ?????????

    ???:Visual Studio 2005, ??? ????? ????????? C#.
  4. ?? ???????????????????? ????,Windows ?????????.
  5. ?????????????, ??????HowToMultiComp?? ????-????? ????, ?? ???? ???OK.
  6. ????????? ????? ??, ?? ????????? ???? ?? ?????? Explorer ??? ??? ??? ??? ?????? Explorer ????? ???? ???? ??, ?? CTRL + ALT + L ??????

    ?? ?? ???? ??? ??? ????? C# Windows ??????? ????????? ?? ??? HowToMultiComp ??? ?????? ????
????? ?? ??? ?????? multilanguage ???, ??? ????? C# ????? ????????? ??? ??????, ?? ?? ???? Visual Basic 2005 ????? ????????? ?? Visual Basic .NET ???????

Visual Basic ????? ????????? ??? ???? ????? ?? ???? ????? ????? ?? ??? Visual Basic ????? ????????? ???, ????? ????? ?? ???? ????:
  1. ?????? Explorer ???, ???? ??????????? 'HowToMultiComp'?? ????? ????,add?? ????-????? ????, ?? ???? ?????? ?????????.
  2. ????? ????,Visual Basic ?????????.

    ???:Visual Studio 2005, ??? ????? ????Visual Basic.
  3. ?? ???????????????????? ????,????? ?????????.
  4. ????????????? ???,NWClassLib?? ????-????? ????, ?? ???? ???OK.

    ?????? ?? ??? Visual Basic 2005 ????? ????????? ?? Visual Basic .NET ????? ???

    Class1.VB?? ?????? ??? ???? ?? ??????
  5. ?? ??????Importsdirectives ????? ?? ????? ???????? ??? ???? ?? ??? shorthand ??? ?????? ????? ??????? ???? ?? ???:
    Imports System.Data
    Imports System.Data.SqlClient
  6. ????? ?? ???? ?? ??? ???DataSet????????? ???????? ?? ?????? ?? ???? ?? ??? ????? ?? ??? ????? ????Class1(?? ???? ?? ???? ???? ???????? ?? ??? ??????? ???????? ?? ???????? ???? ?? ???):
    Public Shared Function GetProducts() As DataSet
    	Dim ds As New DataSet()
    	Dim sqlDS As New SqlDataAdapter("select * from products", New SqlConnection("server=<network address of instance of SQL Server>;database=northwind;integrated security=sspi"))
    	sqlDS.Fill(ds)
    	return ds
    End Function
    
????? C# ????? ????????? ?????? ??? ???? ?? ???, ????? ????? ?? ???? ????::
  1. ?????? Explorer ???, ???? ??????????? 'HowToMultiComp'?? ????? ????,add?? ????-????? ????, ?? ???? ?????? ?????????.
  2. ????? ????,????? C# ?????????.

    ???:Visual Studio 2005, ??? ????? ????????? C#.
  3. ?? ???????????????????? ????,????? ?????????.
  4. ????????????? ???,SBClassLib?? ????-????? ????, ?? ???? ???OK.

    ?????? ?? ??? ????? C# ????? ????????? ??? ????? ???

    Class1.cs??? ???? ?? ?????? ????? ????
  5. ????? ???????? ????? ????shorthand ??????? ???? ?? ??? Class1.cs ??? ????? ?? ????? ?? directives dot ?????? ???? ??? ?????System.Text??? ????? ??System.Collections??? ?????:
    using System.Text;
    using System.Collections;
  6. ??? ????? ??? ??????????????? Class1 ????, ?????? ?? ??????? ????? ???? ??StringBuilder???? ??? ????? ?? ?? ???? ??? ???????? concatenate ???? ?? ??? ???ArrayList:
    public static String BuildString(ArrayList arlStrings)
    {
    	StringBuilder sb = new StringBuilder();
    	
    	foreach(String s in arlStrings)
    	{
    			sb.Append(s);
    			sb.Append(", ");
    	}
    	return sb.ToString();
    }
?? ?? ?? ??? ?? consumes ????? C# Windows ??????? ????????? ??? ???? ???? ????? C# Windows ????? ?? ??? ????????? ??????? ?? ???, ????? ????? ?? ???? ????:
  1. ????? ?? ??? ???????? ?? ?? ????? ????????? ????? ?? ???, ????? ????? ?? ???? ????:
    1. ?????? Explorer ???, ???? ????????????? ???????HowToMultiComp?? ????-????? ????, ?? ???? ????????? ??????.
    2. ?? ????????????????, ????? ?? ????? ????CTRL?????, ????? ????NWClassLib?? ????-????? ????, ?? ???? ???SBClassLib.
    3. ????? ??????????? ?? ????? ???? ??, ?? ??? ????? ??????? ????.
    4. ?? ????? ??????????? ??? ????? ???? ???????? ???????? ???, ????? ????OK.

      ????????? ??? ???????? ?????? ?? ??????? ????? ????????? ?? ????
  2. Form1.cs ??????? ????? ??? ???? ??? ??? Form1.cs ??? ???? ???? ?? ?? ????, ???-????? ????Form1.cs?????? ??? Explorer.
  3. ????? ????? ?? ?????, ?? ???? ??? ???? ?? ??? CTRL + ALT + X ?????Windows ???????.
  4. ??????? ?? ?? ??? ?? ??????, ?? ???? ??? ??? ?? ??? ??? ????? ?? ??????? ?? ??? F4 ??????
  5. ????????? ??????????? ?? ??? ??? ???????????? ?? ??????.
  6. ???? ??? ?????, ?? ?? ????????? ??????????? ?? ??? ??????????? ?????.
  7. ?????? ????DataGrid??????? ?? ????????? ????, ?? ?? ??? ??? ???? ????? ???? ?????DataGrid????????? ???? ???? ?? ??????? ?? ??? ??????? ???? ???
  8. ???-????? ?????????? ?? ??????. ????? Studio .NET ???? ?? ????? ??????? ????,????? ???????
  9. ????? ??? ??????????? ????,????? ??????:
    dataGrid1.DataSource = NWClassLib.Class1.GetProducts().Tables[0];
    ?? ??? ??? ???? ?????? ??????? ???DataGrid???? ?? ???DataSet?????? ???? ??? ??GetProductsmethod of the Class Library.
  10. To create a second????? ????,event handler, double-clickBuild String.
  11. The following code takes the contents of each cell in the first row of the DataGrid up to cell 7, and then adds the contents to anArrayList. TheArrayListis then passed to theSBClassLibrarymethod, which returns a string that appears in aMessageBox?????? ?? ??? ???? ???.. An instance of the class is not necessary, because the method was declared earlier by using the static keyword.

    Add the following code to the????? ????,????? ??????:
    ArrayList arl = new ArrayList();
    for(int i = 0; i <= 8; i++)
    	arl.Add(dataGrid1[0, i].ToString());
    MessageBox.Show(SBClassLib.Class1.BuildString(arl));
???? ???

??? ??????? ?????

Complete Code Listing (Class1.vb)

Imports System.Data
Imports System.Data.SqlClient

Public Class Class1
    Public Shared Function GetProducts() As DataSet
        Dim ds As New DataSet()
        Dim sqlDS As New SqlDataAdapter("select * from products", New SqlConnection("server=<network address of instance of SQL Server>;database=northwind;uid=sa"))
        sqlDS.Fill(ds)
        Return ds
    End Function
End Class
???? ???

Complete Code Listing (Class1.cs)

using System;
using System.Text;
using System.Collections;

namespace SBClassLib
{
	public class Class1
	{
		public Class1()
		{
			
		}

		public static String BuildString(ArrayList arlStrings)
		{
			StringBuilder sb = new StringBuilder();

			foreach(String s in arlStrings)
			{
				sb.Append(s);
				sb.Append(", ");
			}
			return sb.ToString();
		}
	}
}
???? ???

Complete Code Listing (Form1.cs)

using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;

namespace HowToMultiComp
{
	
	public class Form1 : System.Windows.Forms.Form
	{
		private System.Windows.Forms.Button button1;
		private System.Windows.Forms.Button button2;
		private System.Windows.Forms.DataGrid dataGrid1;
		
		private System.ComponentModel.Container components = null;

		public Form1()
		{
			InitializeComponent();
		}

		protected override void Dispose( bool disposing )
		{
			if( disposing )
			{
				if (components != null) 
				{
					components.Dispose();
				}
			}
			base.Dispose( disposing );
		}

		private void InitializeComponent()
		{
			this.button1 = new System.Windows.Forms.Button();
			this.button2 = new System.Windows.Forms.Button();
			this.dataGrid1 = new System.Windows.Forms.DataGrid();
			((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).BeginInit();
			this.SuspendLayout();
			// 
			// button1
			// 
			this.button1.Name = "button1";
			this.button1.Size = new System.Drawing.Size(104, 23);
			this.button1.TabIndex = 0;
			this.button1.Text = "Show Products";
			this.button1.Click += new System.EventHandler(this.button1_Click);
			// 
			// button2
			// 
			this.button2.Location = new System.Drawing.Point(136, 0);
			this.button2.Name = "button2";
			this.button2.Size = new System.Drawing.Size(96, 23);
			this.button2.TabIndex = 1;
			this.button2.Text = "Build String";
			this.button2.Click += new System.EventHandler(this.button2_Click);
			// 
			// dataGrid1
			// 
			this.dataGrid1.DataMember = "";
			this.dataGrid1.HeaderForeColor = System.Drawing.SystemColors.ControlText;
			this.dataGrid1.Location = new System.Drawing.Point(0, 24);
			this.dataGrid1.Name = "dataGrid1";
			this.dataGrid1.Size = new System.Drawing.Size(296, 256);
			this.dataGrid1.TabIndex = 2;
			// 
			// Form1
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
			this.ClientSize = new System.Drawing.Size(292, 273);
			this.Controls.AddRange(new System.Windows.Forms.Control[] {
																		  this.dataGrid1,
																		  this.button2,
																		  this.button1});
			this.Name = "Form1";
			this.Text = "Form1";
			((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).EndInit();
			this.ResumeLayout(false);

		}

		[STAThread]
		static void Main() 
		{
			Application.Run(new Form1());
		}

		private void button1_Click(object sender, System.EventArgs e)
		{
			dataGrid1.DataSource = NWClassLib.Class1.GetProducts().Tables[0];
		}

		private void button2_Click(object sender, System.EventArgs e)
		{
			ArrayList arl = new ArrayList();
			for(int i = 0; i <= 8; i++)
				arl.Add(dataGrid1[0, i].ToString());
			MessageBox.Show(SBClassLib.Class1.BuildString(arl));
		}
	}
}
???:??? Visual Studio 2005 ??? ????????? ???? ?? ???? ???? ?????? ?? ?? ?? Windows ??????? ????????? ????? ???, ????? C# ????? ??????? ?? ?? ????????? ?? ??? ???????? ??? ??? ?? ?????? ?? Form1 ??? ???? ??? ??.. ??????? ?? ???????????? ???? ???? ?? ??????? Form1.cs ?? Form1.designer.cs ??? ???? ??? Form1.cs ??? ???? ??? ?????? The Sesigner.cs file is where the Windows Forms Designer writes the code that implements all the actions that you performed by adding controls. ????? C# 2005 ??? Windows ??????? ??????? ?? ???? ??? ???? ??????? ?? ??? ????? Microsoft ??? ???? ?? ????:
HTTP://msdn2.Microsoft.com/en-us/library/ms173077.aspx
???? ???

???? ???? ?? ??? ???

  1. ????????? ?? ???? ??? ??? ????? ?? ??? F5 ??????
  2. ?? ??????? ????? ???? ??, ????? ????Get Products.

    TheDataGriddisplays all the products from the Northwind products table.
  3. ????? ????,???????? ?????.

    A message box appears that shows the concatenated contents of the cells of the first row, through the cell with an index of 7 (zero-based).
  4. Press SHIFT+F5 to stop debugging and return to Visual Studio .NET.
???? ???

?????? ??????

Make sure that you do not confuse the syntax when you are working with two languages. ????? C# ????? ???? ??, ?? ?????? ????? ???? ??? ????? ????? ?? ??? ??? ?? ?????? ??????? ??? Viusal Basic 2005 ?? Visual Basic .NET ??? intuitive. ?????, ?? ???? ?? ?? "???? Equivalents" ???????? ?? ?? ???????? ???????? ?? ?????? ???? ?? ??? .NET Framework ?????????? ?????????? kit ???? MS ??? ???? ??? ??? ???? ?? ?????:
MS:Help://MS.VCC/MS.MSDNVS/vsintro7/HTML/vxgrfLanguageEquivalents.htm
???? ???

??????

???? ??????? ?? ???, ?????????? MSDN ??? ???? ?? ????::
???? ?????????-Mutli ?????? ??? ??? ??
(VS.60) http://msdn2.Microsoft.com/en-us/library/aa265251 .aspx
???? ???

???

???? ID: 816175 - ????? ???????: 05 ?????? 2010 - ??????: 2.0
???? ???? ???? ??:
  • Microsoft Visual C# 2005 Express Edition
  • Microsoft Visual C# .NET 2003 Standard Edition
  • Microsoft Visual C# .NET 2002 Standard Edition
??????: 
kbhowtomaster kbinterop kbappdev kbhowto kbmt KB816175 KbMthi
???? ?????? ????????
??????????: ?? ???? ?? ???? ??????? ?? ????? ?? Microsoft ????-?????? ?????????? ?????? ?????? ???? ??? ??. Microsoft ???? ??? ????-???????? ?? ????-???????? ????? ?????? ?? ???? ???????? ???? ?? ???? ????? ????? ??? ?? ??? ?????? ?? ???? ???? ???? ??? ????? ??. ???????, ????-???????? ???? ????? ???? ???? ???? ???. ?????, ????????, ?????-???? ?? ??????? ?? ???????? ?? ???? ???, ???? ?? ??? ?????? ???? ???? ??? ????? ??? ?? ???? ??. Microsoft ??????? ??? ???? ?? ?????? ?? ??????????, ????????? ?? ??? ?????? ?? ???? ????? ?? ???? ???????? ?? ??? ???? ????? ?? ??? ????????? ???? ??. Microsoft ????-?????? ?????????? ?? ????? ?????? ?? ?? ??? ??.
?????????? ?? ??????? ????????? ??????? ??:816175

??????????? ???

 

Contact us for more help

Contact us for more help
Connect with Answer Desk for expert help.
Get more support from smallbusiness.support.microsoft.com