Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7812057
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T04:23:18+00:00 2026-06-02T04:23:18+00:00

My task is to migrate this Java code to a C# version, but I’m

  • 0

My task is to migrate this Java code to a C# version, but I’m having trouble with the ValueOf method, since I can’t seem to find a equivalent version for C# (because of the Radix parameter used on Java, 16 in this case).

public String decrypt_string(String s) 
{
  String s1 = "";
  int i = s.length() / 2;
  int[] ai = new int[i];

  for (int j = 0; j < i; j++) 
  {
    // This is the "problematic" line \/
    ai[j] = Integer.valueOf(s.substring(j * 2, j * 2 + 2), 16).intValue();
  }

  int[] ai1 = decrypt_block(ai, i);

  for (int k = 0; k < i; k++) 
  {
    if (ai1[k] != 0)
      s1 = s1 + (char)ai1[k];
  }

return s1;

}

Here is my try, but it failed:

public String decrypt_string(String s)
    {
        String s1 = "";
        int i = s.Length / 2;
        int[] ai = new int[i];

        for (int j = 0; j < i; j++)
        {
            int startIndex = j * 2;
            string tmp = s.Substring(startIndex, 2);
            ai[j] = Int32.Parse (tmp); 
        }

        int[] ai1 = decrypt_block(ai, i);

        for (int k = 0; k < i; k++)
        {
            if (ai1[k] != 0)
                s1 = s1 + (char)ai1[k];
        }
        return s1;
    }

Thanks in advance

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T04:23:21+00:00Added an answer on June 2, 2026 at 4:23 am

    If you are trying to parse a hexadecimal (base-16) number, use this:

    int.Parse (tmp, NumberStyles.HexNumber);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Since Appengine won't allow java multithreading, how then can we migrate our existing multithreaded
I'm trying to make a custom lein task called migrate, so I can say
I've got this ruby on rails project and I want to do db:migrate. But
Task: implement paging of database records suitable for different RDBMS. Method should work for
Task at hand — I have three versions of some code, developed by different
The task is: to compare the software Ada, PUM, Win32. Somebody can tell me
The task is simple, and the answers might be many. But here goes: On
I am getting this error rake db:migrate (in /Users/john/Sites/my_app) rake aborted! Don't know how
Spoiler: It was an outdated version of the rspec-rails gem! I encountered this error
Instead of running each rake task individually like this: rake db:drop rake db:create rake

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.