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 8766407
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T16:32:41+00:00 2026-06-13T16:32:41+00:00

I am a C++ developer and recently moved to C#. Now I am dealing

  • 0

I am a C++ developer and recently moved to C#. Now I am dealing with a textbox in my WPF app where I need to set the test of the textbox. Here is the code:

XAML:

<TextBox Name="Data11" MaxLength="2" Grid.Column="0" Text="{Binding Data11}" />
<TextBox Name="Data12" MaxLength="2" Grid.Column="1" Text="{Binding Data12}" />

ViewModel Class:

private string _Data11;
    public string Data11
    {
        get
        {
            return _Data11;
        }

        set
        {
            _Data11 = value;
            OnPropertyChanged("Data11");
        }
    }

// Description of Data12
private string _Data12;
public string Data12
{
    get
    {
        return _Data12;
    }

    set
    {
        _Data12 = value;
        OnPropertyChanged("Data12");
    }
}

Now on this textbox I need to set the text. Basically In my C++ app I had done it as follows:

m_matchData11->setText(String(String::toHexString((buffer+0), 1)), false);
m_matchData12->setText(String(String::toHexString((buffer+1+4), 1)), false);

If you notice above, ToHexString Creates a string containing a hex dump of a block of binary data. I tried doing this in My WPF app as follows:

Data11 = BitConverter.ToString(buffer, 1);
Data12 = BitConverter.ToString((buffer + 4), 1);

Although first statement seems to work fine, second one throws the following error:

Operator '+' cannot be applied to operands of type 'byte[]' and 'int'

How can I achieve it? 🙂

  • 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-13T16:32:43+00:00Added an answer on June 13, 2026 at 4:32 pm

    You can use the overload of the BitConverter.ToString method which accepts a starting index and length.

    Data12 = BitConverter.ToString(buffer, 4, 1);
    

    This will get the 5th byte in the buffer.

    If you were not using BitConverter.ToString and had to do manual manipulation, you can use Linq’s Take and Skip extension methods.

    EDIT:

    If you’re only ever formatting 1 byte of the buffer, you may be able to do this instead:

    Data12 = buffer[4].ToString("X2");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am a C++ developer and recently started working on C# WPF app. I
I recently inherited an iPhone app. The original developer did not understand memory management
I've been a PHP Developer for a few years now and I've recently been
I am an android app developer, recently I am trying to learn Marmalade to
I am a C++ developer and recently moved to C#. I am working on
I am a C++ developer and I recently moved to C#. I am working
Myself and another developer on my time recently moved from a Core 2 Duo
I'm an Android developer recently moved to Windows Phone 7 development. In Android, we
I've recently uninstalled the Visual Studio 2013 (I think) developer preview and now Visual
I've been experimenting with Adobe Flex recently. Being a long-time server-side web app developer,

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.