我有一個類文件,其中包含一個函數來散列輸入字符串。無法從另一個類調用靜態方法
using System;
using System.Security.Cryptography;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace XHD_Console
{
public class HashingSystem
{
public static string Sha256(string text)
{
string hashString = string.Empty;
//code for hashing here, contains some things i'd rather not release.
return hashString;
}
}
}
我想從形式調用SHA256功能,智能檢測類HashingSystem,但不是功能。有理由嗎?我讀過它需要是靜態的,做到了,但無濟於事。這兩個類都在同一個命名空間,但該類hashingsystem有它自己的文件,hashingsystem.cs
調用的函數:
private void submit_Click(object sender, EventArgs e){
this.EnteredPassword = HashingSystem.sha256(input_Password.Text);
this.DialogResult = DialogResult.OK;
this.Close();
}
這只是一個普通的Windows C#的形式,這對密碼輸入,從而散列函數。 –
使HashingSystem成爲公共類 –
如果兩個類不在同一個Assembly(編譯單元/ Visual Studio項目)中,則將HashingSystem公開。 –