我试图找到一个解决方案但没找到。
问题似乎是公共int号,但我不知道如何解决它。
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace PrimTal
{
class Program
{
public static void Main(string[] args)
{ // } expected
public int number;
number = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Ditt nummer är: " + number);
Console.ReadKey();
}
}
} // type or namespace definition, or end-of-file expected
答案 0 :(得分:1)
属性必须是“外部”,如下所示:
<script type="text/javascript">
function checkForm(theForm) {
"use strict";
/*global alert*/
var formValid = true,
elementCount = 0;
while (elementCount <= theForm.length) {
if (theForm.elements[elementCount].type === "text") {
if (theForm.elements[elementCount].value() === "") {
alert("Please complete all the form elements");
theForm.elements[elementCount].focus();
formValid = false;
break;
}
}
return formValid;
}
} </script>
或者您可以在class Program
{
// Properties
public static int Number {get; set;}
// Methods
public static void Main(string[] args)
{
Number = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Ditt nummer är: " + Number);
Console.ReadKey();
}
}
中使用本地变量int number = Convert.ToInt32(Console.ReadLine());
。