Sunday, September 25, 2016

Constructor and Its Use

What is  constructor?

A special method of the class that will be automatically invoked when an instance of the class is created is called a constructor. The main use of constructors is to initialize private fields of the class while creating an instance for the class. When you
 have not created a constructor in the class, the compiler will automatically create a default constructor in the class. The default constructor initializes all numeric fields in the class to zero and all string and object fields to null.

Some of the key points regarding the Constructor are:
  • A class can have any number of constructors.
  • A constructor doesn't have any return type, not even void.
  • A static constructor can not be a parametrized constructor.
  • Within a class you can create only one static constructor. 
Constructors can be divided into 5 types:
  1. Default Constructor
  2. Parametrized Constructor
  3. Copy Constructor
  4. Static Constructor
  5. Private Constructor 
Now let us see  each constructor type with example as below
Default Constructor

A constructor without any parameters is called a default constructor; in other words this type of constructor does not take parameters. The drawback of a default constructor is that every instance of the class will be initialized to the same values and it is not possible to initialize each instance of the class to different values. The default constructor initializes:
  1. All numeric fields in the class to zero.
  2. All string and object fields to null.
Example
using System;
namespace
 DefaultConstractor
 {
  
  class addition
    {
       
 int a, b; 
        public addition()   //default contructor
        {
            a = 100;
            b = 175;
        }

        public static void Main()
        {
            addition obj = new addition(); //an object is created , constructor is called
            Console.WriteLine(obj.a);
            Console.WriteLine(obj.b);
            Console.Read();
        }
      }
    }
Now run the application, the output will be as in the following:

Parameterized Constructor 

A constructor with at least one parameter is called a parametrized constructor. The advantage of a parametrizedconstructor is that you can initialize each instance of the class to different values.
 
using System;
namespace Constructor
{
   
 class paraconstrctor
    {
     
 public  int a, b;
      
public paraconstrctor(int x, int y)  // decalaring Paremetrized Constructor with ing x,y parameter
        {
            a = x;
            b = y;
        }
   }
    class MainClass
    {
        static void Main()
        {
            paraconstrctor v = new paraconstrctor(100, 175);   // Creating object of Parameterized Constructor and ing values 
            Console.WriteLine("-----------parameterized constructor example by vithal wadje---------------");
            Console.WriteLine("\t");
            Console.WriteLine("value of a=" + v.a );
            Console.WriteLine("value of b=" + v.b);
            Console.Read();
        }
    }
}
Now run the application, the output will be as in the following:

Copy Constructor

The constructor which creates an object by copying variables from another object is called a copy constructor. The purpose of a copy constructor is to initialize a new instance to the values of an existing instance.

Syntax

public employee(employee emp)
{
name=emp.name;
age=emp.age;
}

The copy constructor is invoked by instantiating an object of type employee and ing it the object to be copied.

Example
employee emp1=new  employee (emp2);
Now, emp1 is a copy of emp2.

So let us see its practical implementation.
using System;
namespace copyConstractor
{
    class employee
    {
        private string name;
        private int age;
        public employee(employee emp)   // declaring Copy constructor.
        {
            name = emp.name;
            age = emp.age;
        }
        public employee(string name, int age)  // Instance constructor.
        {
            this.name = name;
            this.age = age;
        }
        public string Details     // Get deatils of employee
        {
            get
            {
                return  " The age of " + name +" is "+ age.ToString();
            }
        }
    }
    class empdetail
    {
        static void Main()
        {
            employee emp1 = new employee("Vithal", 23);  // Create a new employee object.
            employee emp2 = new employee(emp1);          // here is emp1 details is copied to emp2.
            Console.WriteLine(emp2.Details);
            Console.ReadLine();
        }
    }
}
Now run the program, the output will be as follows:


Static Constructor

When a constructor is created as static, it will be invoked only once for all of instances of the class and it is invoked during the creation of the first instance of the class or the first reference to a static member in the class. A static constructor is used to initialize static fields of the class and to write the code that needs to be executed only once.

Some key points of a static constructor is:
  1. A static constructor does not take access modifiers or have parameters.
  2. A static constructor is called automatically to initialize the class before the first instance is created or any static members are referenced.
  3. A static constructor cannot be called directly.
  4. The user has no control on when the static constructor is executed in the program.
  5. A typical use of static constructors is when the class is using a log file and the constructor is used to write entries to this file.
Syntax

class employee
 {
// Static constructor
 
 static employee(){}
 }
Now let us see it with practically
using System;
namespace staticConstractor
{
public class employee
{
    static employee() // Static constructor declaration{Console.WriteLine("The static constructor ");
}
public static void Salary()
 {
    Console.WriteLine();
    Console.WriteLine("The Salary method");
 }
}
class details
{
    static void Main()
    {
        Console.WriteLine("----------Static constrctor example by vithal wadje------------------");
        Console.WriteLine();
        employee.Salary();
        Console.ReadLine();
    }
  }
}
Now run the program the output will be look as in the following:

Private Constructor 
When a constructor is created with a private specifier, it is not possible for other classes to derive from this class, 
neither is it possible to create an instance of this class. They are usually used in classes that contain static members
only. Some key points of a private constructor are:
  1. One use of a private constructor is when we have only static members.
  2. It provides an implementation of a singleton class pattern
  3. Once we provide a constructor that is either private or public or any, the compiler will not add theparameter-less public constructor to the class.
Now let us see it practically.
using System;
namespace defaultConstractor
{
    public class Counter
    {
        private Counter()   //private constrctor declaration
        {
        }
        public static int currentview;
        public static int visitedCount()
        {
            return ++ currentview;
        }
    }
    class viewCountedetails
    {
        static void Main()
        {
            // Counter aCounter = new Counter();   // Error
            Console.WriteLine("-------Private constructor example by vithal wadje----------");
            Console.WriteLine();
            Counter.currentview = 500;
            Counter.visitedCount();
            Console.WriteLine("Now the view count is: {0}", Counter.currentview);
            Console.ReadLine();
        }
    }
}
Now run the application; the output is:

If you uncomment the preceding statement that is commented in the above program then it will generate an error
because the constructor is inaccessible (private).
Summary:


THIS BACKEND VERSION IS NOT SUPPORTED TO DESIGN DATABASE DIAGRAMS OR TABLES. (MS VISUAL DATABASE TOOLS)

He was trying to edit a table within a database which is running on SQL Server 2014 version using his SSMS 2012.  Now, all he needs is upgrading his client tools to 2014. Remember, you can manage/manipulate older versions of your SQL Servers using your 2014 SSMS, However be prepared to face these annoying issues if you are trying the other way.

We have not been able to verify your authority to this domain. Error 12. blogger


Just Add A Record... and CNAME Record in big rock control panel snd name 
Host www n destination address ghs...
n host 2h7mt5qoltu both above... address.. 

Monday, September 19, 2016

Convert Amount Numbers(Rupees, Dollar) into Words using C# and VB

public class ConvertRupeesToWords
    {
        public static string ConvertNumbersToWords(int amountNumber)
        {
            int inputNo = amountNumber;

            if (inputNo == 0)
                return "Zero";

            int[] numbers = new int[4];
            int first = 0;
            int u, h, t;
            System.Text.StringBuilder sbWords = new System.Text.StringBuilder();

            if (inputNo < 0)
            {
                sbWords.Append("Minus ");
                inputNo = -inputNo;
            }

            string[] level0 = {"" ,"One ", "Two ", "Three ", "Four ",
            "Five " ,"Six ", "Seven ", "Eight ", "Nine "};
            string[] level1 = {"Ten ", "Eleven ", "Twelve ", "Thirteen ", "Fourteen ",
            "Fifteen ","Sixteen ","Seventeen ","Eighteen ", "Nineteen "};
            string[] level2 = {"Twenty ", "Thirty ", "Forty ", "Fifty ", "Sixty ",
            "Seventy ","Eighty ", "Ninety "};
            string[] level3 = { "Thousand ", "Lakh ", "Crore " };

            numbers[0] = inputNo % 1000; // units
            numbers[1] = inputNo / 1000;
            numbers[2] = inputNo / 100000;
            numbers[1] = numbers[1] - 100 * numbers[2]; // thousands
            numbers[3] = inputNo / 10000000; // crores
            numbers[2] = numbers[2] - 100 * numbers[3]; // lakhs

            for (int i = 3; i > 0; i--)
            {
                if (numbers[i] != 0)
                {
                    first = i;
                    break;
                }
            }
            for (int i = first; i >= 0; i--)
            {
                if (numbers[i] == 0) continue;
                u = numbers[i] % 10; // ones
                t = numbers[i] / 10;
                h = numbers[i] / 100; // hundreds
                t = t - 10 * h; // tens
                if (h > 0) sbWords.Append(level0[h] + "Hundred ");
                if (u > 0 || t > 0)
                {
                    if (t == 0)
                        sbWords.Append(level0[u]);
                    else if (t == 1)
                        sbWords.Append(level1[u]);
                    else
                        sbWords.Append(level2[t - 2] + level0[u]);
                }
                if (i != 0) sbWords.Append(level3[i - 1]);
            }
            return sbWords.ToString().TrimEnd();
        }
    }

Disable Copy/Paste/Right Click in mvc TextBox

@Html.TextBoxFor(model => model.Days, 
                  new { 
                        @class = "input_box", 
                        id = "txtDays",
                        oncopy="return false", 
                        onpaste="return false" 
                      }
                   ) 

Friday, September 16, 2016

Implicit function evaluation is tuned off by user?

  1. On the Tools menu, click Options.
  2. In the Options dialog box, open the Debugging node, and click General.
  3. If the Debugging node does not appear, click Show all settings.
  4. Select or clear the Enable property evaluation and other implicit function calls check box, and then click OK.

Wednesday, September 7, 2016

An item with the same key has already been added.

Most likely, you have model which contains the same property twice. Perhaps you are using new to hide the base property.

Solution is to override the property or use another name.

If you share your model, we would be able to elaborate more.
or
This error is fairly self-explanatory. Dictionary keys are unique and you cannot have more than one of the same key. To fix this, you should modify your code like so:

    Dictionary<string, string> rct3Features = new Dictionary<string, string>();
    Dictionary<string, string> rct4Features = new Dictionary<string, string>();

    foreach (string line in rct3Lines)
    {
        string[] items = line.Split(new String[] { " " }, 2, StringSplitOptions.None);

        if (!rct3Features.ContainsKey(items[0]))
        {
            rct3Features.Add(items[0], items[1]);
        }

        ////To print out the dictionary (to see if it works)
        //foreach (KeyValuePair<string, string> item in rct3Features)
        //{
        //    Console.WriteLine(item.Key + " " + item.Value);
        //}

    }

The difference between == and === in jQuery/JavaScript

0 == false     // true
0 === false    // false, because they have different types (int, bool)
1 == "1"       // true
1 === "1"      // false, because they have different types (int, string)
null == undefined // true
null === undefined // false

Monday, August 22, 2016

collection of abbreviations in .NET

.NET -  .NET stands for Network Enabled Technology
 .(Dot) = stands for linkage with any application
 N= Network
 E= Enabled 
 T= Technology


ADO – ActiveX Data Object – Microsoft ActiveX Data Objects (ADO) is a collection of Component Object Model objects for accessing different types of data sources.


AJAX – Asynchronouse Javascript and XML – Ajax is a web development technology used for creating interactive web pages with fast data rendering by enabling partial postbacks on a web page (That means a section of the web page is rendered again, instead of the complete web page. This is achieved using Javascript, XML, JSON (Javascript Notation Language) and the XMLHttpRequest object in javascript.


ASP – Active Server Pages – Microsoft’s Server side script engine for creating dynamic web page.


C# – C Sharp – Microsoft Visual C# is an object oriented programming language based on the .NET Framework. It includes features of powerful languages like C++, Java, Delphi and Visual Basic.


CAO – Client Activated Object – Objects created on the server upon the client’s request. This is used in Remoting.


CCW – COM Callable Wrapper – This component is used when a .NET component needs to be used in COM.


CIL – Common Intermediate Language – Its actually a low level human readable language implementation of CLI. All .NET-aware languages compile the source oode to an intermediate language called Common Intermediate Language using the language specific compiler.


CLI – Common Language Infrastructure – This is a subset of CLR and base class libraries that Microsoft has submitted to ECMA so that a third-party vendor can build a .NET runtime on another platform.


CLR – Common Language Runtime – It is the main runtime machine of the Microsoft .NET Framework. It includes the implementation of CLI. The CLR runs code in the form of bytes, called as bytecode and this is termed MSIL in .NET.


CLS – Common Language Specification – A type that is CLS compliant, may be used across any .NET language. CLS is a set of language rules that defines language standards for a .NET language and types declaredin it. While declaring a new type, if we make use of the [CLSCompliant] attribute, the type is forced to conform to the rules of CLS.


COFF – Common Object File Format – It is a specification format for executables.


COM – Component Object Model – reusable software components. The tribe of COM components includes COM+, Distributed COM (DCOM) and ActiveX® Controls.


CSC.exe – C Sharp Compiler utility


CTS – Common Type System – It is at the core of .NET Framework’s cross-language integration, type safety, and high-performance code execution. It defines a common set of types that can be used with many different language syntaxes. Each language (C#, VB.NET, Managed C++, and so on) is free to define any syntax it wishes, but if that language is built on the CLR, it will use at least some of the types defined by the CTS.


DBMS – Database Management System – a software application used for management of databases.


DISCO – Discovery of Web Services. A Web Service has one or more. DISCO files that contain information on how to access its WSDL.


DLL – Dynamic Link Library – a shared reusable library, that exposes an interface of usable methods within it.


DOM – Document Object Model – is a language independent technology that permits scripts to dynamically updated contents of a document (a web page is also a document).


ECMA – European Computer Manufacturer’s Association – Is an internation organisation for computer standards.


GC – Garbage Collector – an automatic memory management system through which objects that are not referenced are cleared up from the memory.


GDI – Graphical Device Interface – is a component in Windows based systems, that performs the activity of representing graphical objects and outputting them to output devices.


GAC – Global Assembly Cache – Is a central repository of reusable libraries in the .NET environment.


GUI – Graphic User Interface – a type of computer interface through which user’s may interact with the Computer using different types of input & output devices with a graphical interface.


GUID – Globally Unique Identifier – is a unique reference number used in applications to refer an object.


HTTP – Hyper Text Transfer Protocol – is a communication protocol used to transfer information in the internet. HTTP is a request-response protocol between servers and clients.


IDE – Integrated Development Environment – is a development environment with source code editor with a compiler(or interpretor), debugging tools, designer, solution explorer, property window, object 
explorer etc.


IDL – Interface Definition Language – is a language for defining software components interface.


ILDASM – Intermediate Language Disassembler – The contents of an assembly may be viewed using the ILDASM utility, that comes with the .NET SDK or the Visual Studio.NET. The ildasm.exe tool may also be usedin the command line compiler.


IIS – Internet Information Server – Is a server that provides services to websites and even hosts websites.


IL – Intermediate Language – is the compiled form of the .NETlanguage source code. When .NET source code is compiled by the language specific compiler (say we compile C# code using csc.exe), it is compiled to a .NET binary, which is platform independent, and is called Intermediate Language code. The .NET binary also comprises of metadata.


JIT – Just in Time (Jitter) – is a technology for boosting the runtime performance of a system. It converts during runtime, code from one format into another, just like IL into native machine code. Note that JIT compilation is processor specific. Say a processor is X86 based, then the JIT compilation will be for this type of processor.


MBR – MarshallByReference – The caller recieves a proxy to the remote object.


MBV – MarshallByValue – The caller recieves a copy of the object in its own application domain.


MDI – Multiple Document Interface – A window that resides under a single parent window.


MSIL – Microsoft Intermediate Language – now called CIL.


MVC - Model View Controller. 


Orcas – Codename for Visual Studio 2008


PE – Portable Executable – an exe format file that is portable.


RAD – Rapid Application Development


RCW – Runtime Callable Wrapper – This component is used when a .NET needs to use a COM 
component.


SAX – Simple API for XML – It is a serial access parser API for XML. The parser is event driven and the event gets triggered when an XML feature is encountered.


SDK – Software Development Kit


SMTP – Simple Mail Transfer Protocol – a text based protocol for sending mails.


SN.exe – Strong Name Utility – a tool to make strong named assemblies.


SQL – Structured Query Language – a language for management of data in a relational structure.


SOAP – Simple Object Access Protocol – a protocol used for exchange of xml based messages 
across networks.


TCP – Transmission Control Protocol – data exchange protocol across networks using streamed sockets.


UI – User Interface


URI – Uniform Resource Identifier


URL – Uniform Resource Locator


UDDI – Universal Description, Discovery and Integration – it is a platform independent business registration across the internet.


WAP – Wireless Access Protocol – a protocol that enables access to the internet from mobile phones and PDAs.


WC – Windows Cardspace – Part of .NET 3.0 framework, that enables users to secure and store digital identities of a person, and a provision to a unified interface for choosing the identity for a particular transaction, like logging in to a website.


WCF – Windows Communication Foundation – Part of .NET 3.0 framework, that enables communication between applications across machines.


WF – Windows Workflow Foundation – Part of .NET 3.0 framework, used for defining, execution and management of reusable workflows.


WKO – Well Known Object – These are MBR types whose lifetime is controlled by the server’s application domain.


WPF – Windows Presentation Foundation – Part of .NET 3.0 framework, is the graphical subsystem of the .NET 3.0 framework.


WSDL – Web Services Description Language – is an XML based language for describing web services.


WML – Wireless Markup Language – is a content format for those devices that use Wireless Application Protocol.


VB.NET – Visual Basic .NET – .NET based language. Its the .NETimplementation of VB6, the most widely used language inthe world.


VBC.exe – VB.NET Compiler


VES – Virtual Execution System – It provides the environment for execution of managed code. It provides direct support for a set of built in data types, defines a hypothetical machine with an associated machine model and state, a set of control flow constructs, and an exception handling model. To a large extent, the purpose of the VES is to provide the support required to execute the Common Intermediate Language instruction set.


VS – Visual Studio


VSS – Visual Source Safe – An IDE by Microsoft, to maintain source code versions and security.


VSTS – Visual Studio Team Suite – Visual Studio Team System – it is an extended version of Visual Studio .NET. It has a set of collaboration and development tools for software development process.


XML – Extensible Markup Language – is a general purpose well formed markup language.