Monday, November 19, 2012

Get and set with C#


You don't need to use set or get. You could write functions named setFoo or getFoo instead of using a property Foo:
  1. class Point {
  2. double x, y;
  3. public Point(double x, double y) {
  4. this.x = x;
  5. this.y = y;
  6. }
  7. public double GetX() { return x; }
  8. public void SetX(double x) { this.x = x; }
  9. public double GetY() { return y; }
  10. public void SetY(double y) { this.y = y; }
  11. }

But that's a real pain -- you'd rather write pt.Y = 3; and be able to write things like pt.Y += 5; , instead of pt.SetY(pt.GetY() + 5); .
So instead C# has properties:
  1. class Point {
  2. double x, y;
  3. public Point(double x, double y) {
  4. this.x = x;
  5. this.y = y;
  6. }
  7. public double X {
  8. get { return x; }
  9. set { x = value; }
  10. }
  11. public double Y {
  12. get { return y; }
  13. set { y = value; }
  14. }
  15. }

Inside the setter, the keyword 'value' is the variable containing the value that is getting assigned to the property Y.
The pattern of having properties directly backed by fields is so common that in C# 3, shortcut syntax was added.
  1. class Point {
  2. public Point(double x, double y) {
  3. X = x;
  4. Y = y;
  5. }
  6. public double X { get; set; }
  7. public double Y { get; set; }
  8. }

There are a few reasons to use properties, instead of public fields. One is that properties can be virtual. Another is that you can make the setters for a property private. Another is that properties have a 'special' meaning to things that inspect classes at runtime. There are frameworks for conveniently talking to databases and for reading and writing objects to and from XML and all sorts of other things -- and they automatically look at the object's properties (and not private fields or other things) to see how to do their job.

Friday, November 16, 2012

Free Javascript Obfuscator and Free PHP Obfuscator


Free Javascript Obfuscator

http://www.javascriptobfuscator.com/default.aspx



Free PHP Obfuscator

http://www.pipsomania.com/best_php_obfuscator.do
http://www.mobilefish.com/services/php_obfuscator/php_obfuscator.php

Monday, November 5, 2012

This example calls the ToInt32(String)

This example calls the ToInt32(String) method to convert an input string to an int . The program catches the two most common exceptions that can be thrown by this method, FormatException and OverflowException. If the number can be incremented without overflowing the integer storage location, the program adds 1 to the result and prints the output




static void Main(string[] args)
{
    int numVal = -1;
    bool repeat = true;

    while (repeat == true)
    {
        Console.WriteLine("Enter a number between −2,147,483,648 and +2,147,483,647 (inclusive).");

        string input = Console.ReadLine();

        // ToInt32 can throw FormatException or OverflowException. 
        try
        {
            numVal = Convert.ToInt32(input);
        }
        catch (FormatException e)
        {
            Console.WriteLine("Input string is not a sequence of digits.");
        }
        catch (OverflowException e)
        {
            Console.WriteLine("The number cannot fit in an Int32.");
        }
        finally
        {
            if (numVal < Int32.MaxValue)
            {
                Console.WriteLine("The new value is {0}", numVal + 1);
            }
            else
            {
                Console.WriteLine("numVal cannot be incremented beyond its current value");
            }
        }
        Console.WriteLine("Go again? Y/N");
        string go = Console.ReadLine();
        if (go == "Y" || go == "y")
        {
            repeat = true;
        }
        else
        {
            repeat = false;
        }
    }
    // Keep the console open in debug mode.
    Console.WriteLine("Press any key to exit.");
    Console.ReadKey();    
}
// Sample Output: 
// Enter a number between -2,147,483,648 and +2,147,483,647 (inclusive). 
// 473 
// The new value is 474 
// Go again? Y/N 
// y 
// Enter a number between -2,147,483,648 and +2,147,483,647 (inclusive). 
// 2147483647 
// numVal cannot be incremented beyond its current value 
// Go again? Y/N 
// Y 
// Enter a number between -2,147,483,648 and +2,147,483,647 (inclusive). 
// -1000 
// The new value is -999 
// Go again? Y/N 
// n 
// Press any key to exit.

C# - DataGridView - Confirmation Dialog on Row Delete

            if (!e.Row.IsNewRow)
            {
                DialogResult dialogResult = MessageBox.Show("Do you want to delete ?", "Delete", MessageBoxButtons.YesNo);
                if (dialogResult == DialogResult.Yes)
                {

                }
                else
                {
                    e.Cancel = true;
                }

            }

Sunday, November 4, 2012

How to change the height of a combobox from designer view?

Change DrawMode property to OwnerDrawVariable, and then change the ItemHeight property. You may need to change IntegralHeight property to false.

Low Level Language


Machine Code

  • A low-level language is one that is close to the fundamentals of the computer's hardware. The lowest-level language is machine code, which is understood directly by the hardware and does not require any interpretation or translation. Machine code consists entirely of strings of binary numbers: the famous zeroes and ones. While it can do anything any other language can do --- indeed, every other language must be translated into machine code by an interpreter --- it is not designed around the needs of the programmer, requires a very close understanding of a computer's processor and devices, and is almost impossible for a human to read.

Assembly Language

  • The next-"higher" programming language is assembly language, which is machine code with the instruction codes replaced by more intuitive commands. The command to put a value of 97 into a memory register called AL, for example --- which would in machine code be "10110000 01100001" --- would in assembly language be "MOV AL, 97", still a cryptic command but one much easier to learn. While it is still inefficient to write and requires a programmer to deal directly with her computer's hardware, it is a higher-level language than machine code because it is more abstract: It is closer to the writer.

High Level Language

  • Modern programmers write even in assembly language very rarely. Instead, they use one of many different higher-level languages like C, Java or Python, which programs called compilers or interpreters can translate into machine code. These languages remove the programmer from the physical realm of the hardware and into logical abstraction: Rather than moving hexadecimal values around memory registers, the programmer works with variables whose contents can be changed; loops that can be repeated until some condition is met; logical statements like IF, AND, THEN, OR and ELSE; and other tools. These languages are designed around the programmer, attentive to the ways she can be given the most power with the least difficulty.

Comparisons

  • High-level languages are not so called because they are "better" than low-level languages. Sometimes, the ability to talk more directly to a computer's processor in assembly language or even machine code can solve problems made difficult by the layers of abstraction in a higher-level language. A very high-level language may deal only with a particular operating system, like Microsoft Visual Basic; or with a particular program, like the "macros" in a word processor. These programs are very useful for someone who wants to manipulate Windows or Word without having to know the intricacies of how each works --- but such a language would be of no use to someone trying to write a program of his own, who would need something lower-level. A programmer thus chooses a language based on the job that he needs to do.

Assembly language


Assembly language
Assembly language is the most basic programming language available for any processor  With assembly language, a programmer works only with operations implemented directly on the physical CPU. Assembly language lacks high-level conveniences such as variables and functions, and it is not portable between various families of processors. Nevertheless, assembly language is the most powerful computer programming language available, and it gives programmers the insight required to write effective code in high-level languages.Machine code for displaying $ sign on lower right corner of screen.10111000, 00000000, 10111000, 10001110, 11011000, 11000110, 00000110,10011110, 00001111, 00100100, 11001101, 0001111

Difference between low level language and High level Language


High level programming languages are more structured, are closer to spoken language and are more intuitive than low level languages. Higher level languages are also easier to read and can typically sometimes work on many different computer operating systems. Some examples of higher level languages are Java, Visual Basic, COBOL, BASIC, C++, and Pascal to name only a few. Lower level languages are typically assembly languages that are machine specific.

Computers run instructions at the binary level, interpreting zeros and ones as instructions. Rather than writing programming code at this level, we've developed languages that compile into the zeros and ones that computers understand. As these languages become more robust, they get further and further way from zeros and ones, becoming higher level languages.

Today's object oriented computer languages allow developers to mimic the real world with objects in code.

To use an analogy, high level programming languages are to spoken languages as low level languages are to Morse code. Morse code is not limited in what it can communicate, but it's not as intuitive or easy to use as spoken language.

Yes and Also... High Level Programming falls in the Area of OOP/Object Oriented Programming. They were design to get much out of Programming, more complexity, flexibility, in a presentation, in Simplicity.

There was a time where all Programming was done in Machine Lanuages, which I can imagine... Gave Programmers a big Headache. Then b, was created then C, Then after awhile C++ Was created which was an adon to C, Making it High Level OOP.

All though not all High level Programming is OOP. OOP Has to have .

Polymorphism.

Encapsulation

etc etc....

Well Not all High Level Programming is OOP. PHP, PERL, RUBY, Which fall in the lines of ''Interpert'' languages, and differ from OOP. Anyway Low Levels actuially refer to The actual Memory, how the CPU Reads, and executes Data. High Levels Are powerful languages, but are presented in ''Human readable Codes'' Defining Variable Names, etc etc.