h1.post-title { color:orange; font-family:verdana,Arial; font-weight:bold; padding-bottom:5px; text-shadow:#64665b 0px 1px 1px; font-size:32px; } -->

Pages

Delete Last character in String

Today, We will discuss about "Delete Last Character from String" using C#.Net


String varLength;
if (textBox1.Text.Length > 0)
{
varLength = textBox1.Text.Substring(0, textBox1.Text.Length - 1);
textBox1.Text = varLength;
}

Types of VB.net Statement:

Here, I give a Tye pf VB.Net Statement with explanation.  Three types of Statement in VB.Net.
  1.  Declaration Statements
  2.  Executable Statements
  3.  Assignment Statements
1) Declaration Statements:
    names of variables,Procedures,Properties ,arrays and constants.
Eg: Dim myName As New string ("Lakshmi Narayanan")
2) Executable Statements:
    Perform a specific action.
    call a procedure
     loop through several statements, or evaluate an expression.
3)Assignment Statements:
    Assignment Statements is also a type of Executable statement.
Me.Text = “Beginner Guide”

ShoutCut Keys in the TextBox


ShoutCut Keys in the TextBox
ShortKey Function
CTRL +H. Remove Last Character.
CTRL +Z. Select All Characters/Last Character in Text Box.
CTRL +X. Cut selected Characters in Text Box.
CTRL +C . Copy Selected Characters in Text Box.
CTRL +P. Paste Selected Characters in Text Box..

DataSet Vs Datareader

Dataset Vs DataReader
DataSet object DataReader object
Read/Write access. Read-only access.
Supports multiple tables from different databases. Supports a single table based on a single SQL query of one database.
Disconnected mode. Connected mode.
Bind to multiple controls . Bind to a single control.
Forward and backward scanning of data . Forward-only scanning of data.
Slower access to data . Faster access to data.
Greater overhead to enable additional features. Lightweight object with very little overhead.
Supported by Visual Studio .NET tools. Must be manually coded.

ExecuteReader,ExcuteNonQuery and ExecuteScaler

ExecuteReader
Use for accessing data. It provides a forward-only, read-only, connected record set.
ExecuteNonQuery
Use for data manipulation, such as Insert, Update, Delete.
ExecuteScalar
Use for retriving 1 row 1 col. value., i.e. Single value. eg: for retriving aggregate function. It is faster than other ways of retriving a single value from DB.

Structure vs Class

Structure Class
Value type and are stored on stack. Reference type and are stored on heap.
“do not support” inheritance. supports inheritance.
used when you want to use a small data structure. better choice for complex data structure.

Value Type vs Reference Type


Value Types Reference Types
All numeric data types. String.
Boolean, Char, and Date. All arrays, even if their elements are value types.
All structures, even if their members are reference types. Class types.
Enumerations, since their underlying type is always SByte, Short, Integer, Long, Byte, UShort, UInteger, or ULong. Delegates.

Boxing and unboxing with Example

Boxing:
Boxing is the Process of Converting a Value Type to the type Object.
Store a value type in the Garbage-Collection.

Unboxing:
              Unboxing is a explicit conversion from the type object to a Value Type.
Checking the object instance to make sure that it is a boxed value of the given value type.
Copying the value from the instance into the value-type variable.
 
Boxing Example:
Int i = 123; // a value type
Object o = i;
UnBoxing Example:
Int i = 123; // a value type
Object o = i;
Int j = (int) o; // UnBoxing
use of converting values:
based on your requirement.
For Example: I want to display a value in MessageBox.If my My value data type is Integer.So I want to convert that value into string .
Ex:
int i=10;
MessageBox.show(i.Tostring());
So I get a integer value into string

Structure vs Enumeration


Structure vs Enumeration
Enumeration Structure
Enumerations are a distinct type consisting of a set of named constants called the enumerator list. A structure is a value type and the instances or objects of a structure are created in stack.
Every enumeration type has an underlying type, which can be any integral type except char. A struct can contain fields, methods, constants, constructors, properties, indexers, operators and even other structure types.
Enumerations are integer-types that make code clearer and easier to maintain. Structs are similar to clases, but are intended to be used to group similar items of data together.

ListBox vs ComboBox

Combo Box List box
preferred Single Selection. short lists and multiple selections.
User can Edit a value at run Time. User can't Edit a value at run Time.

Framework Features

.NET Frame Work 2. 0 Features
Generics
Anonymous methods
Partial class
Nullable type
The new API gives a fine grain control on the behavior of the run time with regards to multithreading, memory allocation, assembly loading and more Full 64-bit support for both the x64 and the IA64 hardware platforms
New personalization features for ASP.NET, such as support for themes, skins and webparts.
.NET Micro Framework
Data Tables

.NET Framework 3.0 Features
Also called WinFX,includes a new set of managed code APIs that are an integral part of Windows Vista and Windows Server 2008 operating systems and provides
Windows Communication Foundation (WCF) – formerly called Indigo; a service-oriented messaging system which allows programs to interoperate locally or remotely similar to web services
Windows Presentation Foundation (WPF) - formerly called Avalon; a new user interface subsystem and API based on XML and vector graphics, which uses 3D computer graphics hardware and Direct3D technologies.
Windows Workflow Foundation (WF) allows for building of task automation and integrated transactions using workflows.
Windows CardSpace, formerly called InfoCard; a software component which securely stores a person’s digital identities and provides a unified interface for choosing the identity for a particular transaction, such as logging in to a website
.NET Framework 3.5 Features
Language Integrated Query (LINQ) for SQL, XML, Dataset, Object
Addin system
p2p base class
Active directory.
ASP.NET Ajax
Anonymous types with static type inference
Paging support for ADO.NET
ADO.NET synchronization API to synchronize local caches and server side data stores
Asynchronous network I/O API
Support for HTTP pipelining and syndication feeds.
New System.CodeDom namespace
.NET Framework 4.0 Features
Common Language Runtime (CLR) – The following sections describe new features in security, parallel computing, performance and diagnostics, dynamic language runtime, and other CLR-related technologies.
Base Class Libraries.
Networking – Enhancements have been made that affect how integrated Windows authentication is handled by the HttpWebRequest, HttpListener, SmtpClient, SslStream, NegotiateStream, and related classes in the System.Net and related namespaces.
Web – The following sections describe new features in ASP.NET core services, Web Forms, Dynamic Data, and Visual Web Developer.
Client – The following sections describe new features in Windows Presentation Foundation (WPF) and Managed Extensibility Framework (MEF). Data.
Communications – Windows Communication Foundation (WCF) provides the new features and enhancements described in the following sections.
Workflow – Windows Workflow Foundation (WF) in .NET Framework 4.0 changes several development paradigms from earlier versions. Workflows are now easier to create, execute, and maintain.

Try Catch Final Statement

In this article, we learn Try .. Catch and Final Statement. First , I describe Try,Catch anfd final? Try: It contains code that may cause exception , The block executes until an exception is thrown or it is completed successfully catch: it can be used without arguments to catch any type of exception. Final: it is useful for cleaning up any resources allocated in the try block. Where to use throw statement? throw statement can be used in the Catch Block. what is mean by throw? used to signal the occurrence of an exception during the Program execution. which class is using for Thrown Execution? System.Exception. Now , we go to Project section. First, we learn Try catch Block statement. Project Description: Loading text file in the Application Create a Project in the C#.net. Project Name is Sample Application for TRY CATCH FINAL Statement. In this Project , We have 2 Forms ,2 Class Files. In that 2 Forms, One Form name is frmtrycatchfinal (It creates when Developer creates a Project) Another Form Name is frmDisplay. One Class file :Program.cs (it creates when Developer creates a Project.) Another class file:FileProcessing.cs. Controls Names Menustrip mnuforApplicaiton Toolstripmenus tryCatchToolStripMenu Toolstripmenus tryCatchFinalToolStripMenu Controls in frmDisplay Controls Names Button btnProcessing RichTextBox RichTextBox1 Coding in FileProcessing.cs Namespace:
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.IO; using System.Windows.Forms; public static void readingFileusingTryCatch(string filePath,System.Windows.Forms.RichTextBox rtb) { try { string text = File.ReadAllText(filePath); rtb.Text = text; } catch (System.Exception e) { MessageBox.Show(e.Message); } } public static void readingFileusingTryCatchFinal(string filePath, System.Windows.Forms.RichTextBox rtb) { try { string text = File.ReadAllText(filePath); rtb.Text = text; } catch (System.Exception e) { MessageBox.Show(e.Message); } finally { MessageBox.Show("File Closed"); } }
Coding in frmtrycatchfinal.cs:
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using System.IO; public static string frmName; private void tryCatchToolStripMenuItem_Click(object sender, EventArgs e) { frmName = Convert.ToString(frmNames.TryCatchExample); frmDispaly frm = new frmDispaly(); frm.Show(); } private void tryCatchFinalToolStripMenuItem_Click(object sender, EventArgs e) { frmName = Convert.ToString(frmNames.TryCatchFinalExample); frmDispaly frm = new frmDispaly(); frm.Show(); } public enum frmNames { TryCatchExample, TryCatchFinalExample } Coding in frmDisplay.cs private void frmDispaly_Load(object sender, EventArgs e) { this.Text = frmtrycatchfinal.frmName; } private void btnProceiing_Click(object sender, EventArgs e) { if (this.Text == Convert.ToString(frmtrycatchfinal.frmNames.TryCatchExample)) { string str = @"C:\text.txt"; FileProcessing.readingFileusingTryCatch(str, richTextBox1); } else if (this.Text == Convert.ToString(frmtrycatchfinal.frmNames.TryCatchFinalExample)) { string str = @"C:\text.txt"; FileProcessing.readingFileusingTryCatchFinal(str, richTextBox1); } }
FileProcessing.readingFileusingTryCatch : It just throws the exception. In our Project : we see the MessageBox Content like this (Could not find the "C:\text.txt"); FileProcessing.readingFileusingTryCatchFinal: It just throws the exception and also release the resources in the Final Boxl. In our Project : MessageBox will show like this (Could not find the "C:\text.txt") and also MessageBox will Show like this ("File Closed") Conclusion: I think, you have an Idea about TRY CATCH FINAL Statement.Thanks for reading this Articles .Please any feedback naraayanan1983@gmail.Com.

Shortcut Keys for DotNet

List of Shortcut Keys in Dot Net
Shortcut Key Usage
Ctrl + N Opens the New Project Dialogue Box
Ctrl + Shift + O Opens the Open File Dialog Box
Ctrl + Shift + A Opens Add New Item window
Ctrl + D Opens Add Existing Item window
Ctrl + S Saves Current Form
Ctrl + Shift + S Saves everything from Application
Alt + Q Exits Visual Studio NET
Ctrl + Z Undo
Ctrl + Shift + Z Redo
Ctrl + X Cuts your selection
Ctrl + C Copies your selection
Ctrl + V Pastes your selection
Ctrl + A Selects All
Del Deletes your selection
Ctrl + F Opens Find window
Ctrl + H Opens Find and Replace window
Ctrl + Shift + H Opens Replace in Files window
Ctrl + Alt + Shift + F12 Opens Find Symbol window
F7 Opens Code Designer window
Shift + F7 Gets you back to Design View
Ctrl + R Opens the Solution Explorer window
Ctrl + Alt + S Opens the Server Explorer window
Ctrl + Shift + C Opens the Class View window
F4 Opens the Properties window
Ctrl + Shift + E Opens the Resource view window
Ctrl + Alt + X Opens the Toolbar window
Shift + Alt + Enter Takes you to Full Screen View
Alt+F8 Opens Macro Explorer window
F2 Opens Object Browser window
Ctrl + Alt + T Opens Document Outline window
Ctrl + Alt + K Opens Task List window
Ctrl + Alt + A Opens Command window
Ctrl + Alt + O Opens Output window
Ctrl + Alt + Y Opens Find Symbol Results window
Ctrl + Alt + F Lists Items under the Favorites Menu in your
Ctrl + Shift + B Builds your project
F5 Runs your Application
Ctrl + F5 Runs your Application without Debugging
Ctrl + Alt + E Opens the Exceptions Dialog Box
F8 Used while Debugging Applications
Shift + F8 Used While Debugging Applications
Ctrl + B Inserts a New Break point
Ctrl + Shift + F9 Clears All Breakpoints
Ctrl + Alt + P Opens the Processes Dialog box
Ctrl + T Opens Customize Toolbox window
Ctrl + Shift + P Runs Temporary Macro
Ctrl + Shift + R Records Temporary Macro
Alt + F11 Opens Macros IDE
Ctrl + F1 Opens Dynamic Help window
Ctrl +Alt + F1 Opens Help window sorted by Contents
Ctrl + Alt + F2 Opens Help window sorted by Index
Ctrl + Alt + F3 Opens Help Search window
Shift + Alt + F2 Opens Index Results window
Shift + Alt + F3 Opens Search Results window

Thanks for Reading

Add Application Key and Value into App Config File

First, we know the meaning of Application Configuration file. Application Configuration file: It is simply says that Store configuration Information. You can store information in the structure like this Key and Value. Each application can have a one configuration file. It is a XML file .you can open any format (like Notepad). Now we will go to our Topic: How to create a Application configuration file in our Application? Let start, Create a Project. "Right click" on the Project name in the Solution Explore. Click "Add" and Click "New Item". Add New Item window will display. Click "Application Configuration file" in the window. Give a Name of the Config file or Default name displays in the window like this (App1.config). Click "ADD" button in the Window. Now, we see the lines in the Config File Now we add some keys and Values between app Setting tag.Before we add a app Setting between configuration tag. Now, How to add a Key and Value using C#.net? ADD a Key and Value: In my Project , I create a Class for ADD and Read Key and value in the Configuration file. Create a Class file. My Class file Name is AppConfig.cs Declare a Some Namespace in the Class. I create a small function for adding a Key and Value in the Configuration file.
using System.Configuration; using System.Windows.Forms; public static void AddintoConfigsetting(string appkeys,string appvalues) { Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None); config.AppSettings.Settings.Add(appkeys, appvalues); config.Save(ConfigurationSaveMode.Modified); ConfigurationManager.RefreshSection("appSetting"); ShowConfigsetting(); } Retrieve the keys and Values from Configuration file public static void ShowConfigsetting() { foreach (string key in ConfigurationManager.AppSettings) { string value = ConfigurationManager.AppSettings[key]; string result = "Keys :" + " " + key + " " + "Key value:" + " " + value; MessageBox.Show(result); } }
Now we go to our form: Create a form Two buttons. One is "Add Key and Value" another one is "Read Keys and Values" add the following code click event of ADD Key and Value button:
AppConfig.AddintoConfigsetting("EmpId","1010");
add the following code click event of Read Keys and Values button AppConfig.ShowConfigsetting(); Conclusion: Today we learn the Application Configuration file. Thanks for spend a value time . Happy Coding!