ASP.NET 1.0 and 1.1 BasicsASP.NET discussion for users new to coding in ASP.NET 1.0 or 1.1. NOT for the older "classic" ASP 3 or the newer ASP.NET 2.0.
Welcome to the p2p.wrox.com Forums.
You are currently viewing the ASP.NET 1.0 and 1.1 Basics section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
Hi, I want to make a static class for my special function like MD5String. I'm pretty sure of my syntaxe but the compilator says on then line (public static class CMD5) : "c:\inetpub\wwwroot\HelloWorld\CMD5.cs(8): Le modificateur 'static' n'est pas valide pour cet élément" or in english : "The modificator 'static' is not valide for this element"
public static class CMD5
{
public static string MD5String(string password)
{
MD5CryptoServiceProvider x = new System.Security.Cryptography.MD5CryptoServiceProvi der();
byte[] bs = Encoding.UTF8.GetBytes(password);
bs = x.ComputeHash(bs);
StringBuilder s = new System.Text.StringBuilder();
foreach (byte b in bs)
{
s.Append(b.ToString("x2").ToLower());
}
password = s.ToString();
return password;
}
}
Note that the change you made wasn't really a 'fix' per se.
You can not use the modifier "static" on a class. You could say that technically, all classes are static, because they are type definitions. You can (as you did) make a METHOD static so you can reference by type without the need for an object instance.
The "sealed" modifier means that your class can not be inherited.
public static class TemperatureConverter
{
public static double CelsiusToFahrenheit(string temperatureCelsius)
{
// Convert argument to double for calculations.
double celsius = System.Double.Parse(temperatureCelsius);