【发布时间】:2017-08-24 11:08:01
【问题描述】:
我有一个类文件,其中包含一个散列输入字符串的函数。
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 函数,intellisense 检测到类 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 成为公共类
-
如果它们确实在同一个命名空间和项目中,它们是否是内部权限无关紧要。
-
OP 最有可能创建一个 HashingSystem 实例,而不是静态调用它