Home
Welcome to Kanbal.com
Convert String to Int in CSharp PDF Print E-mail
Written by Kannan Chandrasekaran   
Monday, 08 March 2010 19:47

CSharp supports converting String to Int in many ways. The following are the few examples to do that.

Example 1:

Int32 intValue = Convert.ToInt32("String Value");

Here the String Value can be 10 or 100 or any number value. This Convert Class contains many methods which, can convert a String to any other datatype which .Net supports

 

Following are the few for your idea.

 

DateTime dateValue = Convert.ToDateTime("String Value");

Double doubleValue = Convert.ToDouble("String Value");

 

I have copied this table from MSDN which could help you to understand this more.

 

Name Description
ChangeType Overloaded. Returns an object of a specified type whose value is equivalent to a specified object.
FromBase64CharArray Converts a subset of a Unicode character array, which encodes binary data as base-64 digits, to an equivalent 8-bit unsigned integer array. Parameters specify the subset in the input array and the number of elements to convert.
FromBase64String Converts the specified string, which encodes binary data as base-64 digits, to an equivalent 8-bit unsigned integer array.
GetTypeCode Returns the TypeCode for the specified object.
IsDBNull Returns an indication whether the specified object is of type DBNull.
ToBase64CharArray Overloaded. Converts a subset of an 8-bit unsigned integer array to an equivalent subset of a Unicode character array encoded with base-64 digits.
ToBase64String Overloaded. Converts the value of an array of 8-bit unsigned integers to its equivalent string representation that is encoded with base-64 digits.
ToBoolean Overloaded. Converts a specified value to an equivalent Boolean value.
ToByte Overloaded. Converts a specified value to an 8-bit unsigned integer.
ToChar Overloaded. Converts a specified value to a Unicode character.
ToDateTime Overloaded. Converts a specified value to a DateTime value.
ToDecimal Overloaded. Converts a specified value to a decimal number.
ToDouble Overloaded. Converts a specified value to a double-precision floating-point number.
ToInt16 Overloaded. Converts a specified value to a 16-bit signed integer.
ToInt32 Overloaded. Converts a specified value to a 32-bit signed integer.
ToInt64 Overloaded. Converts a specified value to a 64-bit signed integer.
ToSByte Overloaded. Converts a specified value to an 8-bit signed integer.
ToSingle Overloaded. Converts a specified value to a single-precision floating-point number.
ToString Overloaded. Converts the specified value to its equivalent string representation.
ToUInt16 Overloaded. Converts a specified value to a 16-bit unsigned integer.
ToUInt32 Overloaded. Converts a specified value to a 32-bit unsigned integer.
ToUInt64 Overloaded. Converts a specified value to a 64-bit unsigned integer.

 

 

The another way is using Parse. Most of the datatype might have this Parse method.

 

Example 2:

 

Int32 x = Int32.Parse("10000");


You can explore this by typing the datatype and place a dot(.) next to the type.  Check the below for more clarity.

 

Double.Parse

DateTime.Parse

 

You can read boxing and unboxing after this.

 

 

Last Updated ( Monday, 08 March 2010 20:15 )
 
Visual Studio 2008 .Net IDE Tips and Tricks PDF Print E-mail
Written by Kannan Chandrasekaran   
Friday, 19 February 2010 10:54

I found some useful documents from my friend Jaffer. This article is not my owe composition. I do not find anyone name in that document to add credit along with this article.

This article could be very useful to all the .Net developer to work faster. Hope you will like this article.

 

1. Record and play temporary macro

Ctrl+Shift+R to record a new temporary macro. Press Ctrl+Shift+R to stop recording. Ctrl+Shift+P to play the recorded macro.

This works similar to *recording* in Vim. If you think you are going to be repeating a set of keyboard keys, then record them once and play them each time after.

2. Multiple copy/pastes

Ctrl+Shift+V cycles through the clipboard ring. You can copy/cut multiple times from one area of code, then go to another area and paste them one after another.

3. Drag and drop code snippets

The Toolbox (Ctrl+Alt+X) window has multiple tabs. You can drag and drop code onto this window and copy it elsewhere. Some tabs do not allow dropping code into them; those that allow will have the appropriate icon. The General tab works for me.

4. Previous cursor positions

Ctrl+- i.e. Ctrl + Hyphen. This cycles you through the code positions you visited.

Ctrl+Shift+- to navigate in the opposite direction.

5. Incremental search

To incrementally search for text as you type, first press Ctrl+i. Then type the word you want to search. Hit backspace to clear a character and enter to finish. Pressing F3 after this will work as usual, i.e. search for the next occurrence of previous search.

Ctrl+i - Ctrl+i works like F3.

6. Matching brace/comment/region/quote

Ctrl+] takes you to the matching brace. It also takes you to the matching comment, region or quote depending on what is at the cursor now.

7. Vertical block selection

Press Alt and then select the area you want with your mouse.

8. Closing/Showing support windows

There are a bunch of necessary/useful windows in the Visual Studio IDE like Properties (F4), Solution Explorer (Ctrl+Alt+L), Output Window (Ctrl+Alt+O), Task List (Ctrl+Alt+K) etc. However, they take up a lot of space. An easy way around this is to use the auto hide feature.

Open the window you want. Right click on its title and choose Auto Hide. The window will dock in whenever your mouse is not hovering over it.

9. Tab groups - group code editor windows

If you have many source code windows open, you can group them logically using tab groups. Right click the tab of the code window and choose New Horizontal Tab Group. This will move the window into a split window, allowing you to see both files. You can add more files to this new tab group and also move files back to the previous group by choosing Move To Previous Tab Group.

10. Track things you have to do with Task List

The Task List window (Ctrl+Alt+K) allows you to keep track of the things you have to do. Right click on the Task List window and choose Show Tasks|All to see a list of tasks. Ctrl+Shift+F12 to cycle through your list of tasks.

By default, comments marked with a TODO will appear in the task list.

11. Edit Task List Comment Tokens

You can add your own set of comment tokens (like the TODO comment token). Goto Tools|Options|Environment|Task List|Comment Tokens and make your changes. You can change the priority appearance of each comment token too.

12. Add Task List Shortcut

Add a shortcut to the task list with Ctrl+K, Ctrl+H. This will add the current line to the task list.

13. Auto-complete

Press Ctrl+Space or Alt+RightArrow to auto-complete the word. Intellisense suggestions may pop up a window if there is more than one possibility.

14. Intellisense suggestions window

Press Ctrl+Shift+Space to bring up the intellisense suggestions window. When giving parameters for functions, I often need to escape the suggestions window to check another part of code. To bring it back, I used to delete a comma and then type it again; but this is easier.

15. Word wrap

Ctrl+R Ctrl+R

or

Tools|Options|Text Editor|All Languages|General|Word Wrap

If you want to set this option for only one language, then choose the appropriate language instead of All Languages.

16. Line numbering

Tools|Options|Text Editor|All Languages|General|Line numbers.

If you want to set this option for only one language, then choose the appropriate language instead of All Languages.

17. Customizing Visual Studio's Code Generation Templates

Customizing Visual Studio's Code Generation Templates.

18. Default Shortcut keys

MSDN.

19. Favorites window

Your IDE also functions as a browser. To see your list of favorites, press Ctrl+Alt+F or choose View|Other Windows|Favorites.

20. Bookmarks

Bookmarks are available through Edit|Bookmarks. Bookmarks allow you to mark places in your code that you would want to come back to.

  • Create/Remove Bookmark - Ctrl+K, Ctrl+K
  • Move to next bookmark - Ctrl+K, Ctrl+N
  • Move to previous bookmark - Ctrl+K, Ctrl+P
  • Clear all bookmarks - Ctrl+K, Ctrl+L

21. Code Formatting

  • Auto-format selection - Ctrl+K, Ctrl+F
  • Convert to lower case - Ctrl+U
  • Convert to upper case - Ctrl+Shift+U
  • Comment selection - Ctrl+K, Ctrl+C
  • Uncomment selection - Ctrl+K, Ctrl+U

22. Outlining

I like this feature that allows me to hide code that is irrelevant to what I'm currently working on.

  • Fold/Unfold the current code block - Ctrl+M, Ctrl+M
  • Unfold all - Ctrl+M, Ctrl+L
  • Stop outlining - Ctrl+M, Ctrl+P
  • Fold all - Ctrl+M, Ctrl+O

23. Build and Debug

  • Build - Ctrl+Shift+B
  • Run - Ctrl+F5
  • Debug - F5

Cycle through build errors - F8

 

Last Updated ( Friday, 19 February 2010 12:02 )
 
Swine flu (H1N1) vaccine for India PDF Print E-mail
Written by Priya   
Wednesday, 09 September 2009 07:11

The first batches of swine flu vaccine rolled out from Baxter Inc labs on Friday. But No hopes for India, The first batch has been supplied to British health network and subsequent batches from Baxter and other pharma companies have been booked by countries such as US and UK which are stockpiling the vaccine to ward off a harsher bout of swine flu.

India is still miles and miles from getting vaccines because the government has not entered into any pre-booking contracts with Novartis, GlaxoSmithKline or any others. India also may not have its indigenous vaccine ready before May 2010.

China has 20-odd companies racing to make the vaccine, with Sinovac Biotech perhaps the first company worldwide to complete clinical trials for swine flu vaccine.

Developing a vaccine is the only way to protect people from the disease, which may become severe with the time of winter and the dire possibility of the H1N1 virus mutating.

As per the news available in internet and TV the swine flu death count increased to 138 so far.

I am writing this article not to panic the people, just would like to create the awareness to the people that we are not safe. Though the government announced many precaution steps and creating awareness that is not sufficient. Still the death count is getting increased. Recently a pregnant lady also dead because of swine flu.

Friends this is the high time to insist the government to book the vaccine for swine flu. Other wise the next generation might read in their history book about our death.

So please insist the government to pre-book the vaccine or to produce the vaccine at the earliest. Since India is having huge population it will be difficult to get vaccine for every one. This not against the government but we need to insist.

We are forwarding somany unnecessary emails Why not this? 

So please raise the flag immediately, We can take your comments to the government.

 

 

 

Last Updated ( Wednesday, 09 September 2009 07:41 )
 
Do View contain Data? PDF Print E-mail
Written by kannan   
Tuesday, 04 August 2009 20:29

Do View contain Data?

Views do not contain or store data.

 
What is GAC ? PDF Print E-mail
Written by ravikumar   
Monday, 03 August 2009 12:39
What is GAC ?
Answer:
Twist :- What are situations when you register .NET assembly in GAC ?
GAC (Global Assembly Cache) is used where shared .NET assembly reside.GAC is used in the
following situations :-
  • If the application has to be shared among several application.
  • If the assembly has some special security requirements like only administratorscan remove the assembly.If the assembly is private then a simple delete ofassembly the assembly file will remove the assembly.
Note :- Registering .NET assembly in GAC can lead to the old problem of DLL hell.
Where COM version was stored in central registry.So GAC should be used when
absolutely necessary
Last Updated ( Wednesday, 02 September 2009 12:04 )
 
More Articles...
<< Start < Prev 1 2 3 4 5 6 7 Next > End >>

Page 1 of 7

Polls

Kanbal is used for?
 

Who's Online

We have 10 guests online

Advertisement

Featured Links:
click here to see FriendsDock.com
Your Ad Here