Thursday, July 28, 2016

CSharp Syntax so what is a type :-)



ClickMeTOtheReferenceSource


(-:    (:-  (-:    (-:   (-:    (:-  (-:    (-:   (-:    (:-  (-:    (-:   (-:    (:-  (-:    (-:   


A variable is nothing but a name given to a storage area that our programs can manipulate. Each variable in C# has a specific type, which determines the size and layout of the variable's memory the range of values that can be stored within that memory and the set of operations that can be applied to the variable.

(-:    (:-  (-:    (-:   (-:    (:-  (-:    (-:   (-:    (:-  (-:    (-:   (-:    (:-  (-:    (-:   

When you define a class, you define a blueprint for a data type. This does not actually define any data, but it does define what the class name means. That is, what an object of the class consists of and what operations can be performed on that object. Objects are instances of a class. The methods and variables that constitute a class are called members of the class.

(-:    (:-  (-:    (-:   (-:    (:-  (-:    (-:   (-:    (:-  (-:    (-:   (-:    (:-  (-:    (-:   

The word polymorphism means having many forms. In object-oriented programming paradigm, polymorphism is often expressed as 'one interface, multiple functions'.
Polymorphism can be static or dynamic. In static polymorphism, the response to a function is determined at the compile time. In dynamic polymorphism, it is decided at run-time.


,,,

Static Polymorphism

The mechanism of linking a function with an object during compile time is called early binding. It is also called static binding. C# provides two techniques to implement static polymorphism. They are:
  • Function overloading
  • Operator overloading
We discuss operator overloading in next chapter.

Function Overloading

You can have multiple definitions for the same function name in the same scope. The definition of the function must differ from each other by the types and/or the number of arguments in the argument list. You cannot overload function declarations that differ only by return type.
,,,

Dynamic Polymorphism

C# allows you to create abstract classes that are used to provide partial class implementation of an interface. Implementation is completed when a derived class inherits from it. Abstract classes contain abstract methods, which are implemented by the derived class. The derived classes have more specialized functionality.

.
When you have a function defined in a class that you want to be implemented in an inherited class(es), you use virtual functions. The virtual functions could be implemented differently in different inherited class and the call to these functions will be decided at runtime.

Dynamic polymorphism is implemented by abstract classes and virtual functions.


(-:    (:-  (-:    (-:   (-:    (:-  (-:    (-:   (-:    (:-  (-:    (-:   (-:    (:-  (-:    (-:   


***
access specifiers

  • Public
  • Private
  • Protected
  • Internal
  • Protected internal
***
C# provides a special data types, the nullable types, to which you can assign normal range of values as well as null values.

The Null Coalescing Operator (??)

The null coalescing operator is used with the nullable value types and reference types. It is used for converting an operand to the type of another nullable (or not) value type operand, where an implicit conversion is possible.
If the value of the first operand is null, then the operator returns the value of the second operand, otherwise it returns the value of the first operand. The following example explains this:
***
An enumeration is a set of named integer constants. An enumerated type is declared using the enum keyword.
***

C# - Preprocessor Directives

The preprocessor directives give instruction to the compiler to preprocess the information before actual compilation starts.
All preprocessor directives begin with #, and only white-space characters may appear before a preprocessor directive on a line. Preprocessor directives are not statements, so they do not end with a semicolon (;).

C# compiler does not have a separate preprocessor; however, the directives are processed as if there was one. In C# the preprocessor directives are used to help in conditional compilation. Unlike C and C++ directives, they are not used to create macros. A preprocessor directive must be the only instruction on a line.
,,,

The #define Preprocessor

The #define preprocessor directive creates symbolic constants.

#define lets you define a symbol such that, by using the symbol as the expression passed to the #if directive, the expression evaluates to true. Its syntax is as follows:
,,,

Conditional Directives

You can use the #if directive to create a conditional directive. Conditional directives are useful for testing a symbol or symbols to check if they evaluate to true. If they do evaluate to true, the compiler evaluates all the code between the #if and the next directive.
Syntax for conditional directive is:
#if symbol [operator symbol]...
Where, symbol is the name of the symbol you want to test. You can also use true and false or prepend the symbol with the negation operator.
The operator symbol is the operator used for evaluating the symbol. Operators could be either of the following:
  • == (equality)
  • != (inequality)
  • && (and)
  • || (or)
You can also group symbols and operators with parentheses. Conditional directives are used for compiling code for a debug build or when compiling for a specific configuration. A conditional directive beginning with a #if directive must explicitly be terminated with a #endif directive.
The following program demonstrates use of conditional directives:
#define DEBUG
#define VC_V10
using System;
public class TestClass
{
   public static void Main()
   {
      #if (DEBUG && !VC_V10)
         Console.WriteLine("DEBUG is defined");
      #elif (!DEBUG && VC_V10)
         Console.WriteLine("VC_V10 is defined");
      #elif (DEBUG && VC_V10)
         Console.WriteLine("DEBUG and VC_V10 are defined");
      #else
         Console.WriteLine("DEBUG and VC_V10 are not defined");
      #endif
      Console.ReadKey();
   }
}

When the above code is compiled and executed, it produces the following result:
,,,,













back slash *\* or forward slash */*



[windows/dos command]

[abstract]
in that the DOS commands only accept back slash '\' in a path string,
so before commands executed, the path string should be disposed.


[]
to replace '\\' to '/'
     
     #include <algorithm>
     std::string backslashPath = "D:\\imDirectory\\imFile.ext";
     std::replace(backslashPath.begin(), backslashPath.end, '\\','/');

to replace '/' with '\\'

     #include <algorithm>
     std::string forwardslashPath = "D:/imDirectory/imFile.ext";
     std::replace(forwardslashPath.begin(), forwardslashPath.end(), '/','\\');


Done :-)
End :-)
__________

[CN]无效开关 - // [EN] Invalid switch - - /x


How to repeat the error ?
______________________________
<>
windows7 64bit
Dos Command Line Interaction
<>
cmd
   DEL /F D:/filenameTObeDeleted.ext

> 无效开关 - "filenameTObeDeleted.ext"
____________________________________


RESOLUTION:




....
....
SYMPTOMS
When you use switches with the xcopy or xcopy32 commands in MS-DOS mode after having chosen Command Prompt Only at the boot menu, or at a command prompt while using the Windows Millennium Edition (Me) Emergency Boot Disk (EBD), you may receive the following error message
Invalid switch - - /x
where x is the switch used, such as /H.
CAUSE
This behavior occurs when you use an unsupported switch with the xcopy or xcopy32 command. In the scenarios that are mentioned in the "Symptoms" section in this article, these commands support only a limited subset of switches.
RESOLUTION
To resolve this behavior, use only the supported switches when Windows starts. The supported switches are listed in the "More Information" section in this article.
MORE INFORMATION

Supported Switches

SwitchDefinition
/cContinues copying even if errors occur.
/iIf a destination does not exist while copying more than one file, this switch assumes that the destination must be a directory.
/qDoes not display file names while copying.
/fDisplays full source and destination file names while copying.
/lDisplays files that would be copied.
/hCopies all files including hidden and system files. 
Note: This switch is only supported at the command prompt in Windows Me.
/rOverwrites read-only files.
/tCreates directory structure, but does not copy files. Does not include empty directories or subdirectories.
/uUpdates the files that already exist in destination.
/kCopies attributes. Normal xcopy will reset read-only attributes.
/yOverwrites existing files without prompting.
/-yPrompts you before overwriting existing files.
/nCopies by using the generated short names.


For a complete listing of switches that are available for xcopy and xcopy32, refer to the following article:
289483 Switches That You Can Use with Xcopy and Xcopy32 Commands

>Done :-)
>End :-)
___________

Saturday, July 23, 2016

Difference What is the difference between Parameter and Argument in c/c++ function description :-)

What is it :-)

    Firstly, we must notice what we often call is Parameter Variable rather than Argument Variable, while we call Argument Value.

    Secondly, Personally, there is a comparative relation between Parameter and Argument. Rather, this is really a context related notion.

    Thirdly, Personally, Parameter is the abstract of the Argument.

    <with consideration of C/C++ function . C++ template >

    ______________________________________________________________
    Followed below are cited material.
    []
    The term goes far back beyond computers. It's been used in astronomy to denote "a piece of information" at least since Chaucer, who used the term in his Treatise on the Astrolabe, to denote the information you get from the almanac for the locations of planets. These are the inputs to calculations to derive where the planet will be at any given date.

    It probably dates back to Latin meanings of argumentum that denote "proof" or "evidence". From astronomy it was adopted by mathematicians who used it for any kind of input to a calculation, and was standard by the 19th century. Computer people adopted it from them. 
    [Arguments](maybe definition or something)
    Parameters and arguments


    ...The term parameter (sometimes called formal parameter) is often used to refer to the variable as found in the function definition, while argument (sometimes called actual parameter) refers to the actual input passed.

    --wikipedia


    [Arguments]
    Argument is often used in the sense of "actual argument" vs. "formal parameter".
    The formal parameter is what's given in the function declaration/definition/prototype, the actual argument is what's passed when calling the function, an instance of a formal parameter, if you will. 

    --stackoverflow

    [Arguments]
    A parameter is the variable which is part of the method’s signature (method declaration). An argument is an expression used when calling the method. 

    --stackoverflow

    [Arguments ]
    function parameter (sometimes called a formal parameter) is a variable declared in the function declaration:
    An argument (sometimes called an actual parameter) is the value that is passed to the function by the caller:
    When a function is called, all of the parameters of the function are created as variables, and the value of the arguments are copied into the parameters. For example:
    When foo() is called with arguments 6 and 7, foo’s parameter x is created and assigned the value of 6, and foo’s parameter y is created and assigned the value of 7.
    Even though parameters are not declared inside the function block, function parameters have local scope. This means that they are created when the function is invoked, and are destroyed when the function block terminates:


--7.1-Function parameters and arguments