Cs0128 c# a local variable or function named is already defined in this scope

Cs0128 c# a local variable or function named is already defined in this scope

Log Into My Account

Create Account

Forgot Password

Create Password

Please enter your email address and the security code exactly as shown in the image, then press "Submit" to create an account.

Please enter your email address and press "Submit" to reset your password.

Please create a password for your account.

Please set a password for your account.

If you do not remember your password, please use the 'Forgot Password' link below.

Email Address
Security Code

Password

New Password

Confirm New Password
Create Account      Forgot Password  Keep Me Logged In

If you do not have an account but would like to check the status of an order, request a change, or report a problem with an order or shipment, please go to our Order Status & Returns page.

C#编译器错误 CS0128

原创

bin_zone 2007-11-09 14:12:38 博主文章分类:个人成长日记 ©著作权

文章标签 职场 C# 休闲 文章分类 .Net 编程语言

©著作权归作者所有:来自51CTO博客作者bin_zone的原创作品,请联系作者获取转载授权,否则将追究法律责任
C#编译器错误 CS0128
https://blog.51cto.com/binzone/49844

今天在使用C#进行编写得的时候发现总是提示CS0128错误。

结果从网上找了些资料才发现,原来是在一个区域内声明了两个名称一样的变量。

来自微软的例子如下:

// CS0128.cs namespace MyNamespace { public class MyClass { public static void Main() { char i; int i; // CS0128 } } }

  • 收藏
  • 评论
  • 举报

上一篇:CSS控制层高问题一解

下一篇:P2P终结者使用感受

Permalink

master

Switch branches/tags

Could not load branches

Nothing to show

{{ refName }}

mono/mcs/errors/cs0128-2.cs / Jump to

Code definitions

C Class Foo Method

Go to file

  • Go to file
  • Copy path
  • Copy permalink

Cannot retrieve contributors at this time

17 lines (16 sloc) 230 Bytes

Raw Blame

Open in GitHub Desktop

  • Open with Desktop
  • View raw
  • View blame

This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters

Show hidden characters

// CS0128: A local variable named `res' is already defined in this scope
// Line: 13
class C
{
static void Foo (int arg)
{
switch (arg) {
case 1:
int res = 1;
break;
case 2:
int res = 2;
break;
}
}
}

Random prekey = new Random(); string[] firstname = {"Александр", "Михаил", "Иван", "Максим", "Артем", "Даниил", "Дмитрий", "Кирилл", "Андрей", "Егор"}; string[] secondname = { "Александов", "Михайлов", "Иванов", "Максимов", "Артемов", "Даниилов", "Дмитров", "Кириллов", "Андреев", "Егоров" }; string fullname = firstname[prekey.Next(0, 10)] + " " + secondname[prekey.Next(0, 10)]; int a = prekey.Next(0, 3); //string introduce; switch (a) { case 0: string introduce = firstname[prekey.Next(0, 10)]; break; case 1: string introduce = secondname[prekey.Next(0, 10)]; break; case 2: string introduce = fullname; break; }