Namespace References In C# Versus .Net?

Aug 22, 2009

In VB.Net you can do something like the following without any issues... just ignore the fact that this is a pretty useless class :-)

Imports System
Public Class Class1
Public Shared Function ArrayToList(ByVal _array() As String) As Collections.Generic.List(Of String)

[code]....

However if you do the same thing in C#...

using System;
public class Class1
{
public static Collections.Generic.List ArrayToList(string[] _array)

[code]....

You will get an error on the line with the return on "Collections.Generic.List" saying "The type or namespace name 'Collections' could not be found (are you missing a using directive or an assembly reference?)"I know that you have to actually have a using directive to System.Collections.Generic to use List but I don't know why. I also don't understand why I don't get the same error in the function declaration, but only in the return statement.

Edit: Just to note, the question is really about the referencing of a sub-namespace such as in the example being able to reference Collections within System.

View 3 Replies


ADVERTISEMENT

.NET Namespace Regarding Explict (named) Versus Implicit (global Or Root) Namespaces?

Sep 27, 2010

I have a solution that contains many projects all using the same root namespace. No code files explicitly name a namespace. So lets say the root namespace is ExampleRootNamespace.Now a problem comes into play when I want to add an explicitly named namespace to one of the code files I am working on. I want to be able to isolate this code from the rest of the assembly to be able to run FxCop against it. So I add something like Namespace Interfaces.CSV to the code file.

This causes any code that references this assembly to need to say Imports ExampleRootNamespace.Interfaces.CSV. So far so good. I can even run FxCop against the assembly. The problem now is that in other assemblies I cannot say any longer things like:

Public class frmInputBoolean Inherits
ExampleRootNameSpace.frmFormTemplate

Visual Studio is now asking me to rename the namespace to:

Public class frmInputBoolean Inherits
Global.ExampleRootNameSpace.frmFormTemplate

There are hundreds of errors related to this. So my questions are:

1) Why would basically naming a namespace under the root for the first time cause issues with the program?

2) Are there any workarounds to this issue without renaming?

I also want to add that with regards to ExampleRootNamespace.Interfaces.CSV I am not referencing this anywhere in the codebase. I'm currently just referencing it from a unit test project. So I don't see why adding this namespace causes an issue.

View 2 Replies

.net - The System.Linq.Dynamic Namespace - Visual Studio Does Not Recognize In The Project Files The System.XXX References

Aug 11, 2011

I would use the System.Linq.Dynamic. I added the specified Dynamic.vb file, that starts like this:

[Code]...

to my (VB.NET)solution. Now Visual Studio does not recognize anymore in the project files the System.XXX references, proposing me to change them to Global.System.XXX

View 1 Replies

VS 2008 Insert References From Application Settings CrystalDecisions References Are Missing

Mar 9, 2011

I have Crystal Reports 2008 installed on my win7 laptop but when i go to insert references from my application settings the CrystalDecisions references are missing and im not able to find them. Note: they do exist in my "c:windowsassembly" folder.

View 3 Replies

[2005] Today.date Versus Now Versus DateTime.Now?

Jan 16, 2009

just want to know what is the difference between these date values?Once some one told me that its difference is server date and client date but not sure which one he meant.Below is 3 type of date currently I'm using and don't know what is the difference between them.

DateTime.Now is from System.DateTime.Now
Now is from Microsoft.VisualBasic.DateAndTime
Today.date is also from System.DateTime

View 4 Replies

Adding Namespace Attribute To XElement - Prevent Blank/empty Namespace On Child Elements?

Mar 17, 2011

I need to read an xml document from a database record into an XDocument object in order for it to be deserialized. So that the deserialization will work, I need to apply a specific namespace to each of the level 1 elements. So XML looks a bit like this:

[Code]...

How do I prevent the blank/empty namespace being added to each child element of the element to which the required namespace has been applied?

View 1 Replies

ERROR : 'Namespace' Can Occur Only At File Or Namespace Level

Jan 29, 2012

Imports System.Windows.Forms

ERROR : 'Namespace' can occur only at file or namespace level

View 5 Replies

Type Or Namespace Name 'Messaging' Does Not Exist In Namespace 'System

Apr 10, 2010

The type or namespace name 'Messaging' does not exist in the namespace 'System' (are you missing an assembly reference?)

View 2 Replies

System Namespace Conflict With Sibling Namespace

Nov 16, 2011

This class is located in the namespace Acme.Infrastructure.Interface.A class with the same name EventArgs exists in the System namespace.In another project in my solution I have a class Acme.BusinessModules.MyModule.MyClass.When attempting to use the EventArgs class I have to fully qualify the class name or the compiler thinks I am using the System.EventArgs class.My understanding of namespace resolution was that the compiler would first look for the class in the current namespace, and then its parents. It seems that the compiler checks in System before it checks in sibling namespaces. Is it correct that System is checked before the sibling? Or is this behaviour caused by other issues (Imports order?)?

View 1 Replies

'Namespace' Statement Must End With A Matching 'End Namespace'?

Dec 8, 2011

I am getting this error,here is my code.

Public Class Sample2
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)Handles Button1.Click

[Code]....

View 4 Replies

.net - X=x+1 Versus X +=1?

Apr 30, 2009

I'm under the impression that these two commands result in the same end, namely incrementing X by 1 but that the latter is probably more efficient.If it is correct, why should the latter be more efficient? Shouldn't they both compile to the same IL?

View 17 Replies

.net - Application "AppName" Is Inventing The Lower-case Namespace "appname", Causing The "AppName" Namespace To Become Ambiguous

Feb 3, 2011

As I say, I've got an application which I'll refer to as "AppName" (note the upper case 'A' and 'N') which, for example, attempts to reference "My.Application.Info.ProductName". Adding a breakpoint and putting a QuickWatch on that call shows the error:

[Code]...

View 1 Replies

IDE Versus EXE Performance In .NET?

Oct 5, 2009

I've developed a .NET application that, among other things, does the following:Uses WebClient to retrieve data from a remote server.
Serves as a socket server to 2 'satellite' applications run on the same machine or on a LAN.When I run the app in the VS IDE, it works great. It quickly gets the data from the remote server and communicates perfectly with the 2 satellites.However, when I build it and run it as an EXE, the response from the remote server is very slow and its communication with the 2 satellite applications become very poor.Is there some important difference between running an app in the IDE and running it as an EXE that could effect it like this?

View 1 Replies

Objective C Versus .net?

Apr 9, 2011

For every member object I have to declare the variable 3 times.One in the declaration. One for property declaration. One to tell the compiler to synthesize all the function. Another one to release all those members from memory.Then I learn about Core Data. I generate diagram, poof the classes are made from me and a lot of things are done behind the screen of that visible classes.

Basically Core Data in Objective C represents some form of relational databases. Of course those databases can have relationship, including many to many relationship. The additional detail of having a third table for many to many relationship is already done.Then, there is indexed property so we can search faster. That's also done.

View 1 Replies

[2008] WPF Versus GDI?

Jan 12, 2009

I have thought of a new project to keep me busy for a while, and it involves a more advanced GUI, specifically I want to display a map and put objects on it or highlight certain areas for example. I've been searching the forum for a little while and ran into two options for more advanced GUI building: WPF and GDI.

View 2 Replies

Add References From Another Project?

Jun 20, 2011

I want to add References from my another project. How Can I do that.

View 3 Replies

Best DI-IOC References For Programmer?

Mar 29, 2010

I code primarily in vb.net. I've been doing basic dependency injection manually and am looking to learn more about DI/IoC and maybe use a DI/IoC framework/container like Ninject. There are lots of examples and write-ups using Java and C# code. I'm looking for the best resources for vb.net programmers. Likewise, is there a particular framework that would be easiest for a vb.net programmer to pick up?

View 3 Replies

Find The References To Add?

Mar 27, 2010

I am trying out Modi but i cant seem to find the references to add. I have office2k7 but cant find Microsoft Office Document Imaging 12.0 Type Library in com tab. Also cant find the dll in C:Program FilesCommon FilesMicrosoft SharedMODI

View 2 Replies

References Are Always Droped?

Mar 23, 2009

I am using vb.net 2005.After I rebuild the solution that has many projects, some references in a project are always dropped.I have to manully add them again.

View 1 Replies

Where Do The References Go In VS 2008

Nov 30, 2009

I've used VS 2005 for a while, when you use 'Add Reference' it puts the DLL in the BIN directory. I did this with VS 2008 and I don't see the DLL in the BIN. I am using an Application ( not a website ).

View 9 Replies

.net 2003 Versus Mysql?

Jun 21, 2010

i am not able to use connection string?

View 1 Replies

Application.Exit() Versus End?

Dec 8, 2010

Can anyone tell me what the technical difference is between Application.Exit() and End?Why would you choose to use one over the other, for example?

View 5 Replies

Asp.net - SQL Transactions: TSQL Versus .NET?

Nov 19, 2010

I wanted to know what (if any) differences there are to using the SQL Transaction within the application versus written into the stored procedure using TSQL statement. We would need to restructure the stored procs and vb code to get this to work and I'm not sure it would be worth the effort at this time.

Public Sub RetrieveTData(ByVal cID As String, ByVal cnn As SqlConnection) As Boolean
Dim sqlTran As SqlTransaction
cnn.Open()
sqlTran = cnn.BeginTransaction

[code].....

We aren't certain whether the timeout is occurring in DataAlreadyTransferred() or usp_BigNasty_CopyDataFromDB1toDB2 due to how the try/catch is written. We can restructure this code, but will take a week or so to get it to production (no errors occur on test/dev today)

DB1 - permanent storage, used by other applications as well
DB2 - working set, used only by Web App

DataAlreadyTransferred(cID) first checks to see if DB2 has any copies of the records, if DB2 does and those records are clean it deletes them (data could have changed in DB1 and we want the most up-to-date version). If DB2's data is dirty it is left alone and no data is deleted.

usp_BigNasty_CopyDataFromDB1toDB2 copies rows from approximately 20-30 different tables and copies over the perm copies from DB1 into DB2, essentially creating a working set from which the Web App can access

We are aware this is inefficient and are examining ways to improve it, just haven't had time yet... I believe by having the transactions in the app code it's locking many more tables than is really needed. If we move them to the stored procs, less tables will be locked at one time thus improving our chances of removing deadlock conditions/timeout issues we're seeing today. Just not sure on this..

View 2 Replies

C# - Appropriate To Use Generics Versus Inheritance?

Apr 28, 2009

What are the situations and their associated benefits of using Generics over Inheritance and vice-versa, and how should they be best combined?I'm going to try to state the motivation for this question as best I can:I have a class as shown below:

[Code]...

Now suppose I have a repository that takes an InformationReturn argument, that has to strore different fields in a DB depending on the type of Info object T is. Is it better to create different repositories each for the type T is; one repository that uses reflection to determine the type; or is there a better way using inheritance capabilities over/with generics?

View 6 Replies

C# - Division By Zero: Int Versus Float?

Dec 18, 2010

Deviding an int by zero, will throw an exception, but a float won't - at least in Java. Why a float have an additional NaN info, while int haven't?

View 6 Replies

Case Versus If Then Statements.

Apr 26, 2011

i have a program, three radios, and 2 check boxes. the Radios use a constant value and do a multiplication. check one applies a discount. no problem.

the last takes the values of all three radios does a comaparison and displays a label if false, performs a subtraction if true and shows savings.problem>

very convoluted using if statements. and the output is often wrong(i know this is a logic error) i can not find the fault.

would it be easier to use case statments. can and will post code if requested. as it is in if then format currently it is rather long.
Sometimes the answer is so blindingly obvious i fail to see it.

View 4 Replies

Generics Versus Extensions?

Nov 8, 2009

This is my problem:

<System.Runtime.CompilerServices.Extension()> _
Function CastAs(Of TSource As TTarget, TTarget)(ByVal array As TSource()) As TTarget()
Return Global.System.Array.ConvertAll(array, Function(src As TSource) DirectCast(src, TTarget))
End Function

View 10 Replies

IDE :: VB 2008 Versus 2005?

Sep 1, 2009

I have a book from a friend called "Teach Yourself Visual Basic in 21 Days" and so far what I have read has been very nice and easy to look at as well as understand. It also seems like it will do what it says it will do. One problem is it was published in 2006 so it uses VB Studios 2005. There is a rather large difference between 2005 and the new 2008 Express edition and I see the new 2010 beta so I wondered: "light from above, is it worth looking for the 2005 edition of Visual Basic Studios Express Edition or should I rather just look for another book and start working with this 2008 edition? I really fancy this book on the 2005 edition but seeing as it doesn't even have the XP window styles in the figures it might be a little outdated and this new 2010 edition might blow away 2008! I am so confused. Should I throw out the old and go with the new, or should I work with 2008 until IT'S time is up? Is it worth it in this new economy and fast paced evolving career opportunity?" Well, I didn't get a response form the great Computer Techie in The Sky, so I am asking you... What should I do? I understand that it might be better to learn with this new 2008 edition but even still I would imagine their are some 2005 based programs out there people use that might need updating. As a beginning programmer I don't know where to go.

View 3 Replies

Overloads Versus Overrides In .net?

Oct 24, 2011

What are the behaviors difference for the Previous Property of Other1 and Other2 Class.Note than the return type of the ovrloaded Previous Property of Other2 as bean changed to Other2 while it stay as Base for Other1.

Public Class Base
Private _Previous as Base
Protected Overridable ReadOnly Property Previous As Base

[code]....

View 2 Replies

Reference Versus Instantiate?

Aug 25, 2011

what actually goes on inside the pc when I reference an object vs when I instantiate it.

Like this

Guys joe; (reference)

Joe = new Guys; (instantiate).So what goes on inside the computer for each line above.

View 15 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved