Login
Register
Tutorials
Forum
Career Development
Resources
Reviews
Jobs
Interview
Communities
Projects
Training
Silverlight Games
|
Bookmarks
|
New Members FAQ
|
Mentor
|
Code Converter
|
IT Companies
|
Peer Appraisal
|
Members
|
Revenue Sharing
|
Computer Jokes
|
New Posts
|
Social
|
Talk to Webmaster Tony John
Online Members
Ranjith Kumar
satyapriyanayak
More...
Forums
»
.NET
»
General
»
Need clarification to declare a variable.
Posted Date:
10 Aug 2012
Posted By::
Balamurali
Member Level:
Silver
Member Rank:
0
Points
: 2
Responses:
2
Hi all,
I would like to know which of the following is best and why?
1. Dim sName As String = String.Empty
2. Dim sName = String.Empty (Implicit convertion)
Tweet
Responses
#683842 Author:
Pawan Awasthi
Member Level:
Diamond
Member Rank:
4
Date: 10/Aug/2012 Rating:
Points
: 4
Hai Bala,
See the inline comments of your query:
1. Dim sName As String = String.Empty
Here the variable is declared with the type and then initialized. So if this variable is used further then there is no need to convert it to the respective type as it is already of string type.
2. Dim sName = String.Empty (Implicit convertion)
In this case, the variable is not having any type and initialized with the string variable. So when used, you need to convert it in to respective type and then you can use it. So here it will consume more cpu cycles and performance wise it will be slow as it need to first type cast and use it.
Hope it will be helpful to you.
Regards,
Pawan Awasthi(DNS MVM)
+91 8143683708 (pawansoftit@gmail.com)
Outstanding Contribution Award..NTT Data Inc
#684035 Author:
Ajesh Madhukar Dalvi
Member Level:
Silver
Member Rank:
340
Date: 12/Aug/2012 Rating:
Points
: -1
[Response removed by Admin for invalid response to the thread or violation of
forum policies
.]
Post Reply
You must
Sign In
to post a response.
Tweet
Next :
Tips And Tricks All Time Need For Your Computer
Previous :
Very happy Gokulashtami to all my Indian friends
Return to Discussion Forum
Post New Message
Category:
Related Messages
Diff In Oracle Error Displaying Messages.
Software requiremernt specification
About Subreports in crystal reports
PHP - urgent pls help
Crystal Report Problem
Follow us on Twitter:
https://twitter.com/dotnetspider
Active Members
Today
Ultimaterengan
(42)
Priya jain
(16)
Asheej T K
(16)
Last 7 Days
baskar
(312)
naveensanagase...
(183)
Asheej T K
(179)
more...
Awards & Gifts
Email subscription
.NET Jobs
.NET Articles
.NET Forums
Articles Rss Feeds
Forum Rss Feeds