Concat 3 binary fields

Posted on 2011-10-14
Last Modified: 2012-05-12
The solution in the related question works but now I need to concat 3 binary fields..They're phone numbers. How can I do this? is varbinary in the database
ip.Phone = new Binary(Encoding.UTF8.GetBytes(phone1.Value) & (Encoding.UTF8.GetBytes(phone2.Value) & (Encoding.UTF8.GetBytes(phone3.Value));

Open in new window

Question by:Camillia
    LVL 17

    Accepted Solution

    Hello, If the Value property is string, then try:
    ip.Phone = new Binary(Encoding.UTF8.GetBytes(phone1.Value + phone2.Value + phone3.Value));

    Open in new window

    LVL 17

    Expert Comment

    by:Carlos Villegas
    Otherwise if Value is byte[], then try:
    ip.Phone = new Binary(Encoding.UTF8.GetBytes(Encoding.UTF8.GetString(phone1.Value) + Encoding.UTF8.GetString(phone2.Value) + Encoding.UTF8.GetString(phone3.Value)));

    Open in new window

    LVL 17

    Expert Comment

    by:Carlos Villegas
    Also, if Value is a System.Data.Linq.Binary type, then try:
    ip.Phone = new Binary(Encoding.UTF8.GetBytes(Encoding.UTF8.GetString(phone1.Value.ToArray()) + Encoding.UTF8.GetString(phone2.Value.ToArray()) + Encoding.UTF8.GetString(phone3.Value.ToArray())));

    Open in new window


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    6 Surprising Benefits of Threat Intelligence

    All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

    This article discusses the ASP.NET AJAX ModalPopupExtender control. In this article we will show how to use the ModalPopupExtender control, how to display/show/call the ASP.NET AJAX ModalPopupExtender control from javascript, how to show/display/cal…
    It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
    Sending a Secure fax is easy with eFax Corporate ( First, Just open a new email message.  In the To field, type your recipient's fax number You can even send a secure international fax — just include t…
    Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

    760 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    12 Experts available now in Live!

    Get 1:1 Help Now