Entries:
Comments:
Posts:

Loading User Information from Channel 9

Something went wrong getting user information from Channel 9

Latest Achievement:

Loading User Information from MSDN

Something went wrong getting user information from MSDN

Visual Studio Achievements

Latest Achievement:

Loading Visual Studio Achievements

Something went wrong getting the Visual Studio Achievements

Discussions

lensman lensman
  • Learning C# as a first language

    Pet Basic 2.0, 6502/808x/680x0 assembler, Pascal, COMAL, Fortran, Cobol, Finac, C, C++, VB, VB.NET, C#.  Throw in the various web variants and the list keeps growing.

  • confused by 32 bit vs 64 bit

    When you compile a C#/ VB.NET application you get a .DLL/.EXE which can be either 32 bit, 64 bit, or either.

    It really boils down to where the resulting code is run.  If you specify 32 bit, you get a .DLL/.exe which can only run in 32 bit mode.  That means also if you attempt to link/call/invoke a method which is in 64 bit world you get an error.  The same is true if you do the reverse.  If you do not specify which your code can run on either assuming it does not invoke a library in a different format.

    For example if you were writing a application which needed to use crystal reports XI-R2, you cannot code a 64 bit application.  Crystal XI-R2 is pure 32 bit and knows nothing about 64 bit worlds.  In my opinion this requires you specify 32 bit as the "either" method could result in an unexpected error should your application be run on a 64 bit client.

     

    One interesting quirk:  .DLL's appear to run based upon the caller's method of use.  The same .DLL can be used by both 32 and 64 bit applications.  They will be in different application memory spaces but they will function.  I tend to code my .DLL's as "either" unless I am coding a module which must interface to a 32bit library.  This allows my "either" .DLL's to be used on 64 bit web servers or 32 bit web servers without recompilation.

     

     

     

  • Can't figure out why I can't create this SQL ​relationshi​p.

    @qwert231:

    Does that not mean that a row exists in the table "family_fishing_reg" which does not have a matching value in table "family_fishing"?  The foreign key constraint implies that all values much match the constraint or the constraint cannot be implemented.

     

    Fix your data and then add the constraint.

     

     

     

  • Access 2010 Web database form question

    If you are using access (any flavor) behind a website you have serious problems.  Access is by definition insecure.  If you want to be taken over by every script kiddie out there go right ahead.

    I would recommend just about anything, including SQL Express, over Access.

  • DB design question

    The lack of a primary key is not a crime.  In tables which provide history of changes such a condition is not an aberation.  A constraint to prevent duplicates is a good idea.

  • C# Dice Roll Program With Image.

    @figuerres: Agreed that anything is better than a console app.  Based upon the content of his example he is focused on a console application (thus the ascii art).  It reminds me of a programming assignment I got about 25 years ago in a intro to programming course.

  • C# Dice Roll Program With Image.

    Your real question is how to display the 6 sided dice.  You have logic to find the dice.

    You can try something like:

     

            private static String DisplayDie(int diceRoll)
            {
                String sOutput = String.Empty;
                // Each dice is shown in a 3 bit x 3 array of dots
                // to simulate a dot on a dice.  Each "dot" is 3 
                // characters wide.  Thus you display 3 rows of dots
                // which has 3 dots wide.
                short[][] dieImage = new short[][] {
                    new short[] { 0, 2, 0},
                    new short[] { 2, 0, 2},
                    new short[] { 2, 2, 2},
                    new short[] { 5, 0, 5},
                    new short[] { 5, 2, 5},
                    new short[] { 7, 0, 7}
                };
                // only process valid dice rolls
                if ((diceRoll >= 1) &&
                    (diceRoll <= 6)) 
                {
                    sOutput = String.Format("{0}\n", "-".PadLeft(11,'-'));
                    foreach (short s in dieImage[diceRoll-1]) 
                    {
                        String sTxt = String.Empty;
                        int sv = s;
                        // right shift bits and determine if 
                        // a zero or one was the right most bit
                        // and use that value to display a "digit".
                        for (int i = 0; i <= 2; i++) 
                        {
                            if ((sv % 2) == 0) 
                            {
                                // right most bit was a zero, display as spaces
                                sTxt = String.Format("{0}{1}", "   ", sTxt);
                            }
                            else 
                            {
                                // right most bit was a one.  Display as a dot
                                sTxt = String.Format("{0}{1}", " 0 ", sTxt);
                            }
                            sv = (sv / 2); // update current value
                        }
                        sOutput += String.Format("|{0}|\n",sTxt);
                    }
                    sOutput += String.Format("{0}\n", "-".PadLeft(11,'-'));
                }
                return sOutput;
            }
    

     

  • Noobie C# question; PONG

    @evildictaitor:Well, to be honest robust is in the eye of the beholder.  I admit your code and my code function the same.

    The use of !timer1.Enabled relies upon a quirk of the compiler.  It is not guaranteed to work 100% of the time on all systems.  Yes, it does today, but tomorrow may be another question.  I have been coding since the late 70's and have worked on systems where that statement would fail.

    I use the code "timer1.Enabled = (timer1.Enabled == false)" primarily to overstate my intention so that any viewer of the code cannot help know the purpose of the desired action.  Something that is intuitive to you might not be intuitive to the "newbie".  I code for readability not necessarily the least number of keystrokes.  (heck, I threw in a comment just to ensure the obvious)

     

     

  • Noobie C# question; PONG

    @infinitum3d:While you could use a label or a picture box or image (or anything for that matter), you are now asking another question where object oriented programming can come to light.

    You are in essence (so far) discussing a generic "object" which is to be moved in a given direction based upon a timing event.  You have not actually described what the object is, how it is physically displayed, and so on.  Your "ball" class would probably be an attribute of a larger object denoting the physical location in "n-space" of that object.

     

  • Noobie C# question; PONG

    @evildictaitor:

     

    I prefer the more robust:

     

    timer1.Enabled = (timer1.Enabled == false);  // reverses state of timer