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

  • Home
  • SEARCH
  • 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 7778929
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T18:31:19+00:00 2026-06-01T18:31:19+00:00

I have a simple application that has richTextBox and button. User enters numbers(integers) into

  • 0

I have a simple application that has richTextBox and button.
User enters numbers(integers) into richTextBox (one number per line).

When He click the button I want to generate a sql query.

Basically it works if I pass integers into query like this:

SELECT price from products where ID IN (1, 2, 3, 4)

This is when user inputs 1,2,3,4 as lines in richTextBox.

But I would like pass binary(8) instead of integers.

This is my original line of code:

cmdString += " IN (" + string.Join(", ", richTextBox1.Lines) + ") ";

I have tried to change it with LINQ like this:

cmdString += " IN ("
+ string.Join(", ", richTextBox1.Lines.Select(c => 
    { c = "0x"+Convert.ToString(Convert.ToInt32(c), 16); 
     return c; 
    }).ToArray())
+ ") ";

What I would like to get:

For example convert:

 1   to  0x0000000000000001
30   to  0x000000000000001E

I hope You get the point.

Update:

I’ve done this:

textBox1.Text = string.Join(", ", richTextBox1.Lines.Select(c =>
    {
        c = "0x" + "0000000000000000".Substring(0, (16 - Convert.ToString(Convert.ToInt32(c), 16).Length)) + Convert.ToString(Convert.ToInt32(c), 16);
        return c;
    }).ToArray());

Any ideas how to remove second Convert.ToString(Convert.ToInt32(c)) usage? Or maybe do it in another way?

  • 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-01T18:31:21+00:00Added an answer on June 1, 2026 at 6:31 pm

    I’ll do this in foreach loop:

    var query = "Select ... In( ";
    
    foreach(var item in Lines)
    {
       int a = 0;
       if (!int.TryParse(item, out a))
         throw new IllegalInputException();
       query += "0x" + Convert.ToString(a, 16).PadLeft(16, '0');
    }
    ...
    

    Or you can do it in your linq query but not easy to read as foreach one:

    cmdString += " IN (" 
    + string.Join(", ", richTextBox1.Lines.Select(c => 
        { c = "0x"+Convert.ToString(Convert.ToInt32(c), 16)
                   .PadLeft(16, '0'); 
         return c; 
        }).ToArray())  
    
    + ") ";
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a simple application that has a single page with a button that
I have a simple Android application that has a TabBar and one of the
I have a simple Desktop Facebook application that allows the user to retrieve some
I have a fairly simple C# application that has builds a large hashtable. The
I have a simple vb6 editor type application which has a richtextbox as the
I have developed an application that has a list of items in one frame;
I have a simple Spring MVC application that looks up some user details from
I have a simple application that shows the user an image (in a UIImageView)
I have created a rails application that has a simple RESTful json API. This
I have a simple photo taking application that has the following design: [Consider the

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.