以下の画像のようなファイル構造があります
私のプロジェクト名はmyIGNOU
であり、フォルダ内のこれらすべてのファイル内のクラス クラスApp_Code
は で記述されていmyIGNOU
namespace
ます。
AppSettings.cs
しかし、ファイル内のファイルからクラスにアクセスできるのに、ファイル内Code2.cs
から同じクラスにアクセスできないAppSettings.cs
ことに本当にイライラしていますCode1.cs
。Code1.cs
andのファイル名を入れ替えてみまし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}))$");
}
}
}