0

以下の画像のようなファイル構造があります

ここに画像の説明を入力

私のプロジェクト名はmyIGNOUであり、フォルダ内のこれらすべてのファイル内のクラス クラスApp_Codeは で記述されていmyIGNOU namespaceます。

AppSettings.csしかし、ファイル内のファイルからクラスにアクセスできるのに、ファイル内Code2.csから同じクラスにアクセスできないAppSettings.csことに本当にイライラしていますCode1.csCode1.csandのファイル名を入れ替えてみましCode2.csたが、うまくいきませんでした。動作はまったく同じです。同じフォルダーに別のクラス (別のファイル) を追加しようとしましたがAppSettings.cs、この新しく作成されたクラスのファイルのクラスにまだアクセスできません。

Code1.cs各ファイルにいくつかのクラス (すべてパブリック) がある場合に、他のファイルを展開するボタンがないのはなぜですか?

私は何が欠けています..? App_Codeフォルダの名前も変更しようとしましたが、やはりうまくいきません。
ファイルのすべてのクラスはCode1.cs、残りのクラスでアクセスできます。

lasdk;adj.jコンパイル時エラーが発生しないなど、何か間違ったことを入力すると、これら3つのファイルのいずれもコンパイルされていないと思います。しかし、私はCompilation Error実行時に取得しています。のように、このフォルダにない他のファイルについても同じではありませんDefault.aspx.cs。このため、コンパイル時にエラーが発生します。

ここですべてのコードを見ることができます

ここにコードがあります

AppSettings.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace myIGNOU
{
    public static class AppSettings
    {
        //public static string ConnectionString { get { return "Data Source = .; Initial Catalog = SMR; Integrated Security = True;"; } }
        //public static string ConnectionString2 { get { return "Data Source = .; Initial Catalog = shashwat; Integrated Security = True;"; } }
        public static string ConnectionString { get { return "Data Source=IDCSQL2.znetlive.com,1234;Initial Catalog=smrbobdn;User Id=shashwat;Password=xxxx;"; } }
        public static string ConnectionString2 { get { return "Data Source=IDCSQL2.znetlive.com,1234;Initial Catalog=shashwat;User Id=shashwat;Password=xxxx;"; } }
        public static string ConStr1 { get { return "Data Source=.; Initial Catalog=myIGNOU; Integrated Security=true;"; } }

        public static DateTime Now { get { return DateTime.Now.AddMinutes(0); } }
    }
}

Code1.cs

using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.IO;
using System.Net;

namespace myIGNOU
{
    public class Student
    {
        public Student(string enrollmentNumber)
        {
            EN = enrollmentNumber;
        }
        public bool LoadFromDB()
        {
            bool ret = false;
            SqlCommand com = new SqlCommand("SELECT * FROM StudentInfo WHERE EN = @en", new SqlConnection());

            return ret;
        }
        public string EN { get; set; }
        public string Name { get; private set; }
        public string FatherName { get; private set; }
        public string Program { get; private set; }
        public string Address { get; private set; }
        public string Mobile { get; set; }
        public string Email { get; set; }
        public uint RC { get; private set; }
        public uint SC { get; private set; }
        public uint AdmissionYear { get; private set; }
        public uint AdmissionValid { get; private set; }
        public uint UpdatedOn { get; private set; }
    }

    public class HttpRequest
    {

        string GetPageAsString(string path, string method, string dataToPost)
        {
           return "...";
        }
    }



    public class Program
    {
    }
    public class Semester
    {
    }
    public class Course
    {
    }
}

Code2.cs

using System.Data.SqlClient;
using System.Text.RegularExpressions;
using System.Net.Mail;

namespace myIGNOU
{
    public class CustomHttpRequest
    {

    }
    public class Emails
    {
        public static MailAddressCollection GetAllEmails()
        {
            MailAddressCollection cc = new MailAddressCollection();
            SqlCommand com = new SqlCommand("SELECT Email from myignou", new SqlConnection(AppSettings.ConnectionString));
            com.Connection.Open();
            SqlDataReader dr = com.ExecuteReader();
            while (dr.Read())
            {
                cc.Add(dr[0].ToString());
            }
            com.Connection.Close();
            return cc;
        }
    }
    public class RegexUtilities
    {
        public static bool IsValidEmail(string strIn)
        {
            // Return true if strIn is in valid e-mail format.
            return Regex.IsMatch(strIn,
                   @"^(?("")(""[^""]+?""@)|(([0-9a-zA-Z]((\.(?!\.))|[-!#\$%&'\*\+/=\?\^`\{\}\|~\w])*)(?<=[0-9a-zA-Z])@))" +
                   @"(?(\[)(\[(\d{1,3}\.){3}\d{1,3}\])|(([0-9a-zA-Z][-\w]*[0-9a-zA-Z]\.)+[a-zA-Z]{2,6}))$");
        }
    }
}
4

0 に答える 0