我有一个类文件,其中包含一个函数来散列输入字符串。无法从另一个类调用静态方法
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公开。 –