-
Feb 11th, 2021, 05:52 AM
#1
Thread Starter
New Member
Convert Max address to Serial
Mac Address is : FC-45-96-95-17-18
Code:
string str = this.GetMacAddress().ToString();
int int32_1 = Convert.ToInt32(str.Substring(2, 1), 16);
int int32_2 = Convert.ToInt32(str.Substring(4, 1), 16);
int num1 = Math.Abs(int32_1 - int32_2);
int num2 = int32_1 * 2 + num1;
int num3 = int32_2 * 3 + num1;
if (this.txtN1.Text.Equals(num2.ToString().PadLeft(2, '0') + num3.ToString().PadLeft(2, '0')))
whats the serial ?
Last edited by dday9; Feb 11th, 2021 at 11:10 AM.
-
Feb 11th, 2021, 06:46 AM
#2
Re: Convert Max address to Serial
Your code appears to be C# and is not complete anyway. What are you trying to do?
-
Feb 11th, 2021, 06:59 AM
#3
Re: Convert Max address to Serial
Please provide a FULL and CLEAR explanation of the problem. Explain what you're trying to achieve, how you're trying to achieve it and what happens when you try.
-
Feb 11th, 2021, 08:46 AM
#4
Thread Starter
New Member
Re: Convert Max address to Serial
Code:
using System;
public class Program
{
public static void Main()
{
String str = "FC4596951718".ToString();
int int32_1 = Convert.ToInt32(str.Substring(2,1),16);
int int32_2 = Convert.ToInt32(str.Substring(4,1),16);
int num1 = Math.Abs(int32_1 - int32_2);
int num2 = int32_1 * 2 + num1;
int num3 = int32_2 * 3 + num1;
Console.WriteLine(int32_1);
Console.WriteLine(int32_2);
Console.WriteLine(num1);
Console.WriteLine(num2);
Console.WriteLine(num3);
}
}
Result:
the serial is : 1332
Last edited by dday9; Feb 11th, 2021 at 12:17 PM.
-
Feb 11th, 2021, 08:50 AM
#5
Thread Starter
New Member
Re: Convert Max address to Serial
yes you are right the code is writing with C#
-
Feb 11th, 2021, 08:54 AM
#6
Thread Starter
New Member
Re: Convert Max address to Serial
my calc was wrong from Math.Abs but now the code working good
thx
-
Feb 11th, 2021, 08:54 AM
#7
Re: Convert Max address to Serial
The best friend of any programmer is a search engine
"Don't wish it was easier, wish you were better. Don't wish for less problems, wish for more skills. Don't wish for less challenges, wish for more wisdom" (J. Rohn)
“They did not know it was impossible so they did it” (Mark Twain)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|