嗨,,,, frnds我正在创建在线评估我收到错误 [英] Hi, , , , frnds I am creating the online assessment I am getting the error

查看:85
本文介绍了嗨,,,, frnds我正在创建在线评估我收到错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨,,,, frnds我正在创建在线评估我收到程序中缺少的错误命名空间或参考



我试过的:



 String sid,sname; 
sid = ddlSubjects.SelectedItem.Value;
sname = ddlSubjects.SelectedItem.Text;
考试考试=新考试(Int32.Parse(Session [mid]。ToString()),Int32.Parse(sid),sname);在这里我收到错误
exam.GetQuestions();
Session.Add(问题,考试);
Response.Redirect(examine.aspx);

解决方案

某个名称空间中有一个Examination类,但是如果你不告诉编译器看哪个命名空间,它就不知道在哪里找到那个类,它会给出错误。



你可以将命名空间添加到考试(即用替换考试> Namespace.Examination ,其中命名空间是一个实际的命名空间,可能包含点。)



或者,而不是,您可以使用使用语句在文件顶部添加该命名空间:

 使用 NamespaceContainingExamination;  //  实际名称空间名称 

之后,你可以使用考试就像你一样。



命名空间(C#编程指南)| Microsoft Docs [ ^ ]

使用指令( C#参考)| Microsoft Docs [ ^ ]


hi,,,, frnds i am creating the online assessment i am getting the error namespace or reference missing in the program

What I have tried:

String sid, sname;
            sid = ddlSubjects.SelectedItem.Value;
            sname = ddlSubjects.SelectedItem.Text;
            Examination exam = new Examination(Int32.Parse(Session["mid"].ToString()), Int32.Parse(sid), sname);  here i am getting the error 
            exam.GetQuestions();
            Session.Add("questions", exam);
            Response.Redirect("examination.aspx");

解决方案

You have an Examination class in a namespace somewhere, but if you don't tell the compiler in which namespace to look, it won't know where to find that class and it will give an error.

You can either prepend the namespace to Examination (i.e. replacing Examination with Namespace.Examination, where Namespace is an actual namespace, which may contain dots).

Or, instead of that, you can add that namespace on top of your file with a using statement:

using NamespaceContainingExamination; // actual namespace name there

And after that, you can just use Examination like you did.

Namespaces (C# Programming Guide) | Microsoft Docs[^]
using Directive (C# Reference) | Microsoft Docs[^]


这篇关于嗨,,,, frnds我正在创建在线评估我收到错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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