我创建了一个游戏,其中包含另一个类中列出的许多方法......所以我想全局使用这个类,所以我将它存储在一个 DLL 中(以便能够在其他几个项目中使用它)
但不知何故,Visual Studio 没有找到我引用的那个 DLL 的命名空间!
有什么我做错了吗?“fncs”DLL 的命名空间也称为“fncs”...它们都是在相同版本的 .NET 中创建的...提前致谢!
DLL:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Net;
using System.Runtime.InteropServices;
namespace fncs {
class io {
public static bool write(string dir, object[] obj) {
try {
File.WriteAllLines(dir, ((System.Collections.IEnumerable)obj).Cast<object>().Select(x => x.ToString()).ToArray());
} catch (Exception e) {
return false;
} return true;
}
public static string read(string dir) {
StreamReader r = new StreamReader(dir);
return r.ReadToEnd();
}
public static void saveToServer(string x, string y) {
// hidden
}
}
class rc {
public static void echo(object obj) {
Console.WriteLine(obj.ToString());
}
public static string get() {
return Console.ReadLine();
}
}
class math {
public static int add(int a, int b) {
return a + b;
}
}
class web {
public static string getWebContent(string url) {
WebClient c = new WebClient();
string s;
try {
s = c.DownloadString(url);
} catch (WebException w) {
return w.ToString();
} return s;
}
public static string OpenSQL() {
SQLConnection SQL = new SQLConnection();
return SQL.BindStatus();
}
public static string post(string Url, params string[] postdata) {
string result = string.Empty;
string data = string.Empty;
System.Text.ASCIIEncoding ascii = new ASCIIEncoding();
if (postdata.Length % 2 != 0) {
Console.WriteLine("Parameters must be even , \"user\" , \"value\" , ... etc");
return string.Empty;
}
for (int i = 0; i < postdata.Length; i += 2) {
data += string.Format("&{0}={1}", postdata[i], postdata[i + 1]);
}
data = data.Remove(0, 1);
byte[] bytesarr = ascii.GetBytes(data);
try {
WebRequest request = WebRequest.Create(Url);
request.Method = "POST";
request.ContentType = "application/x-www-form-urlencoded";
request.ContentLength = bytesarr.Length;
System.IO.Stream streamwriter = request.GetRequestStream();
streamwriter.Write(bytesarr, 0, bytesarr.Length);
streamwriter.Close();
WebResponse response = request.GetResponse();
streamwriter = response.GetResponseStream();
System.IO.StreamReader streamread = new System.IO.StreamReader(streamwriter);
result = streamread.ReadToEnd();
streamread.Close();
} catch (Exception ex) {
Console.WriteLine(ex.Message);
}
return result;
}
}
class SQLConnection {
public string conn_bind;
public SQLConnection() {
//hidden
}
public string BindStatus() {
return conn_bind;
}
}
}