Click here to Skip to main content
15,886,689 members
Home / Discussions / C#
   

C#

 
GeneralRe: Using UserControls Pin
WebMaster28-Aug-12 10:08
WebMaster28-Aug-12 10:08 
GeneralRe: Using UserControls Pin
Ian Shlasko28-Aug-12 10:15
Ian Shlasko28-Aug-12 10:15 
QuestionPDF417 generator and reader supports Arabic Pin
dinadido28-Aug-12 8:15
dinadido28-Aug-12 8:15 
AnswerRe: PDF417 generator and reader supports Arabic Pin
Ian Shlasko28-Aug-12 9:22
Ian Shlasko28-Aug-12 9:22 
GeneralRe: PDF417 generator and reader supports Arabic Pin
dinadido28-Aug-12 11:18
dinadido28-Aug-12 11:18 
GeneralRe: PDF417 generator and reader supports Arabic Pin
Ian Shlasko28-Aug-12 11:25
Ian Shlasko28-Aug-12 11:25 
QuestionUpdating portion of byte array not working Pin
MichCl28-Aug-12 2:02
MichCl28-Aug-12 2:02 
AnswerRe: Updating portion of byte array not working Pin
Keith Barrow28-Aug-12 2:32
professionalKeith Barrow28-Aug-12 2:32 
You have a try without a catch or finally, so I don't see how your code is compiling. Simplifying your problem:

C#
private int convertStringToByte(String theString, ref byte theByte)
    {
        theByte = System.Convert.ToByte(theString);
        return 1;
    }

    public void RunSnippet()
    {
        byte[] tempByteArr = new byte[]{1};
        convertStringToByte("3", ref tempByteArr[0]);
        Console.WriteLine(tempByteArr[0]);
    }


The above code works, so the basic logic of what you have is OK, just an implementation problem.

I'd suggest a different methodology. It looks like you are trying to implement Byte.TryParse method, you may want to look at it. If you need more information than a plain boolean, implementing your own is easy:


C#
public static int ConvertStringToByte(string s, out byte result)
    {
        try
        {
            theByte = System.Convert.ToByte(theString);

        }
        catch
        {
            return 0;
            //Or whatever - don't catch "all exceptions" like this!
        }
        return 1;
    }


GeneralRe: Updating portion of byte array not working Pin
MichCl28-Aug-12 2:38
MichCl28-Aug-12 2:38 
GeneralRe: Updating portion of byte array not working Pin
Keith Barrow28-Aug-12 2:47
professionalKeith Barrow28-Aug-12 2:47 
GeneralRe: Updating portion of byte array not working Pin
MichCl28-Aug-12 3:16
MichCl28-Aug-12 3:16 
GeneralRe: Updating portion of byte array not working Pin
Keith Barrow28-Aug-12 3:54
professionalKeith Barrow28-Aug-12 3:54 
SuggestionRe: Updating portion of byte array not working Pin
Shameel28-Aug-12 4:00
professionalShameel28-Aug-12 4:00 
GeneralRe: Updating portion of byte array not working Pin
Keith Barrow28-Aug-12 4:32
professionalKeith Barrow28-Aug-12 4:32 
GeneralRe: Updating portion of byte array not working Pin
DaveyM6928-Aug-12 5:16
professionalDaveyM6928-Aug-12 5:16 
GeneralRe: Updating portion of byte array not working Pin
Keith Barrow28-Aug-12 6:07
professionalKeith Barrow28-Aug-12 6:07 
GeneralRe: Updating portion of byte array not working Pin
MichCl28-Aug-12 4:33
MichCl28-Aug-12 4:33 
SuggestionRe: Updating portion of byte array not working Pin
Shameel28-Aug-12 4:43
professionalShameel28-Aug-12 4:43 
GeneralRe: Updating portion of byte array not working Pin
MichCl28-Aug-12 2:43
MichCl28-Aug-12 2:43 
Questionhello Pin
ri198728-Aug-12 1:10
ri198728-Aug-12 1:10 
AnswerRe: hello PinPopular
Keith Barrow28-Aug-12 1:20
professionalKeith Barrow28-Aug-12 1:20 
SuggestionRe: hello Pin
pramod.hegde28-Aug-12 1:57
professionalpramod.hegde28-Aug-12 1:57 
AnswerRe: hello Pin
Ravi Bhavnani28-Aug-12 5:26
professionalRavi Bhavnani28-Aug-12 5:26 
Questionhow to store datas in excel. Pin
Anusha Sridhar28-Aug-12 0:09
Anusha Sridhar28-Aug-12 0:09 
AnswerRe: how to store datas in excel. PinPopular
Eddy Vluggen28-Aug-12 0:21
professionalEddy Vluggen28-Aug-12 0:21 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.