Click here to Skip to main content
15,917,641 members
Home / Discussions / C#
   

C#

 
GeneralRe: Java -> C# Programming Problem , plz help ! Pin
wgarnett22-Mar-09 4:30
wgarnett22-Mar-09 4:30 
GeneralRe: Java -> C# Programming Problem , plz help ! Pin
0x3c022-Mar-09 4:37
0x3c022-Mar-09 4:37 
GeneralRe: Java -> C# Programming Problem , plz help ! Pin
wgarnett22-Mar-09 5:04
wgarnett22-Mar-09 5:04 
GeneralRe: Java -> C# Programming Problem , plz help ! Pin
Yusuf22-Mar-09 5:15
Yusuf22-Mar-09 5:15 
AnswerRe: Java -> C# Programming Problem , plz help ! Pin
0x3c022-Mar-09 5:55
0x3c022-Mar-09 5:55 
GeneralRe: Java -> C# Programming Problem , plz help ! Pin
SeMartens22-Mar-09 5:42
SeMartens22-Mar-09 5:42 
GeneralRe: Java -> C# Programming Problem , plz help ! Pin
wgarnett22-Mar-09 6:24
wgarnett22-Mar-09 6:24 
GeneralRe: Java -> C# Programming Problem , plz help ! Pin
wgarnett22-Mar-09 6:31
wgarnett22-Mar-09 6:31 
Thanks everyone again !
but the code that I modified is below,but still has problem:

---------------------------------------------------------------

using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;

public class MyGen
{
private const string LL = "keygen";

public virtual string getSerial(string userId, string licenseNum)
{

        DateTime dDate = DateTime.Now.AddYears(3);<br />
        dDate.Add(1, 3);<br />
        dDate.Add(6, -1);


licenseNum = Int32.Parse(licenseNum).ToString("D3");
string verTime = "-" + dDate.ToString("yyMMdd") + "0";
string type = "YE3MP-";
string need = new StringBuilder(userId.Substring(0, 1)).Append(type).Append("300").Append(licenseNum).Append(verTime).ToString();
string dx = new StringBuilder(need).Append(LL).Append(userId).ToString();
int suf = this.decode(dx);
string code = new StringBuilder(need).Append(Convert.ToString(suf)).ToString();
return this.change(code);
}

private int decode(string s)
{
int i;
char[] ac;
int j;
int k;
i = 0;
ac = s.ToCharArray();
j = 0;
k = ac.Length;
while (j < k)
{
i = (31 * i) + ac[j];
j++;
}
return Math.Abs(i);
}

private string change(string s)
{
sbyte[] abyte0;
char[] ac;
int i;
int k;
int j;

        abyte0 = s;<br />
        ac = new char[s.Length];<br />
        i = 0;<br />
        k = s.Length;<br />
        while (i < k)<br />
        {<br />
            j = char.ConvertToUtf32(s, i);


if ((j >= 48) && (j <= 57))
{
j = (((j - 48) + 5) % 10) + 48;
}
else if ((j >= 65) && (j <= 90))
{
j = (((j - 65) + 13) % 26) + 65;
}
else if ((j >= 97) && (j <= 122))
{
j = (((j - 97) + 13) % 26) + 97;
}
ac[i] = (char)j;
i++;
}
return Convert.ToString(ac);
}

public MyGen()
: base()
{
}

static void Main(string[] args)
{
try
{
Console.WriteLine("please input register name:");
string userId = null;
userId = System.Console.ReadLine();
MyGen MyGen = new MyGen();
string res = MyGen.getSerial(userId, "5");
Console.WriteLine("Serial:" + res);
System.Console.ReadLine();
}
catch (IOException ex)
{
}
}
}

garnett

GeneralRe: Java -&gt; C# Programming Problem , plz help ! Pin
0x3c022-Mar-09 6:48
0x3c022-Mar-09 6:48 
GeneralRe: Java -&gt; C# Programming Problem , plz help ! Pin
wgarnett22-Mar-09 7:08
wgarnett22-Mar-09 7:08 
GeneralRe: Java -&gt; C# Programming Problem , plz help ! Pin
0x3c022-Mar-09 8:33
0x3c022-Mar-09 8:33 
GeneralRe: Java -&gt; C# Programming Problem , plz help ! Pin
wgarnett22-Mar-09 15:12
wgarnett22-Mar-09 15:12 
GeneralRe: Java -&gt; C# Programming Problem , plz help ! Pin
0x3c022-Mar-09 21:03
0x3c022-Mar-09 21:03 
GeneralRe: Java -&gt; C# Programming Problem , plz help ! Pin
wgarnett22-Mar-09 21:14
wgarnett22-Mar-09 21:14 
GeneralRe: Java -&gt; C# Programming Problem , plz help ! Pin
0x3c023-Mar-09 5:41
0x3c023-Mar-09 5:41 
GeneralRe: Java -&gt; C# Programming Problem , plz help ! Pin
wgarnett23-Mar-09 6:22
wgarnett23-Mar-09 6:22 
QuestionDrawing graphics in a new thread causes flicker Pin
_Martin_22-Mar-09 2:39
_Martin_22-Mar-09 2:39 
AnswerRe: Drawing graphics in a new thread causes flicker Pin
0x3c022-Mar-09 2:56
0x3c022-Mar-09 2:56 
QuestionHow do I get the Objects of the Solution Explorer(or General the Files of the Project) in an Visual Studio Integration Package Pin
Dromar22-Mar-09 2:10
Dromar22-Mar-09 2:10 
AnswerRe: How do I get the Objects of the Solution Explorer(or General the Files of the Project) in an Visual Studio Integration Package Pin
tech60322-Mar-09 3:59
tech60322-Mar-09 3:59 
AnswerRe: How do I get the Objects of the Solution Explorer(or General the Files of the Project) in an Visual Studio Integration Package Pin
Yusuf22-Mar-09 5:19
Yusuf22-Mar-09 5:19 
QuestionHow to Sort Dataset ? Pin
E_Gold21-Mar-09 22:33
E_Gold21-Mar-09 22:33 
AnswerRe: How to Sort Dataset ? Pin
Abhishek Sur22-Mar-09 0:04
professionalAbhishek Sur22-Mar-09 0:04 
GeneralRe: How to Sort Dataset ? Pin
E_Gold22-Mar-09 1:03
E_Gold22-Mar-09 1:03 
GeneralRe: How to Sort Dataset ? Pin
Henry Minute22-Mar-09 2:23
Henry Minute22-Mar-09 2:23 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.