Recent update: 2008-3-21
Does C# provide any function which will create and return unique identifier? Thanks,
I want to do something where I can take any variable, reference type (no problem) or value, and have a reference to the data, rather than just the data (in the case of value variables). Example: //create three objects for reference object obj1, obj2, obj3; //create two value variables and one ...
If I call the "Dispose" method on an object, would it be equal to null? And If I make the object equal to null instead, would it be same as calling "Dispose" method of the object?For example:SomeObject obj1 = SomeObject();SomeObject obj2 = SomeObject();obj1.Dispose();obj2 = ...
is there some sample, where can to see the diference between both?
I can use as opertator, for the objets that I created?.
758 byte By
johnk at 2008-2-28
hello,currently i have forms that are selected from a menu but multiple instances seem to be allowed. i would like to have only a single instance of each form allowed, but would like the user to be able to recall the form again after closing the form. other threads on this topic have code that ...
Can someone, for the life of me, explain why this code won't compile with CS0305 as the compiler error?Thanks very much, -Trey-using System;using System.Collections.Generic; public class MyContainer<T> : IEnumerable<T>{ public void Add( T item ) { impl.Add( item ); } public void ...
1479 byte By
JoeR at 2008-2-26
Does anyone know why the following doesn't work?interface B is derrived from interface A, and should contain an implicit conversion from B to Aerror CS0309: The type 'constraint_bug.interface_b<T>' must be convertible to ...
2269 byte By
DeKale at 2008-2-25
The new generics in C# 2.0 are really breath taking, but I've got some problems with sorting a Generic List. I've got a List<KeyValueType<TKey, TValue>>, so this is a list containing another generic type. Now I would like to sort this list by the TKey type of the ...
I'm currently trying to use generics to make my interfaces a little bit more flexible. Unfortunately I seem to have hit a problem with the compiler complaining when I try to use an interface as an input parameter, if that interface requires a type to be defined. I'm not sure if I explained ...
Hi,Why does the code below not work? I've constrained the T type of the Bar class to be a "Foo" but I still get compiler error "Error 1 'T': cannot provide arguments when creating an instance of a variable type" (beta 2 - 8.0.50215.44). Since I've constrained T to be a class rather than ...
Hi Peter, Thanks for responding. Converting to string doesn't help me convert the code unfortunately. Thanks!
Can someone tell me the primary differences between C#.Net and C++.Net? If I learn one, will I necessarily be learning the other? Which one would you recommend that I learn first? Currently, I know C++ but I program professionally in VB6. I am looking to make the transition into the Visual ...
1092 byte By
bzurer at 2008-2-21
"Generic methods should provide type parameter" http://www.gotdotnet.com/team/fxcop/docs/rules.aspx?version=1.32&url=/Design/GenericMethodsShouldProvideTypeParameter.html public sealed class ReflectionAgent{ public static T GetCustomAttribute<T>(MemberInfo memberInfo) { if (memberInfo ...
1303 byte By
MikeF at 2008-2-20
I have a question about a line of code. I was looking at some code on how to implement ftp in .net 2.0 and saw this line of code.response = (FtpWebResponse)request.GetResponse(); my question is, why is FtpWebResponse in parenthisies?Usually you only see parenthisies when you use a method and ...
3546 byte By
DeKale at 2008-2-19
I am trying to create a indexer on a property, but I can't get it working. I want to have something like this: class MyClass { public string Value[string key] { /* Compiler Error */ get { /* Do some processing and Return something. */ } set { /* Set the content to the key value. */ } } } Of ...
Sir, I have a certain part of code which i have changed to visaul C# from c++ it is giving me some problems.I am not able to understand how to solve it. ...
558 byte By
Amit at 2008-2-18
Hi,I have a wierd problem. I have in my development enviornment, a Windows XP Machine installed with Oracle 10g (both DB and Client on the same machine). The same machine is being used as web server. On this I have a ASP.Net 2005 Application which connects to an Oracle DB and this application works...
When I try to build a web site solution I get the follwing errors :Error 1 (0): error CS0006: Metadata file 'C:\WINDOWS\Microsoft.NET\Framework\v2.0.50215\Temporary ASP.NET Files\testeinf\15e74bc9\75b17dc3\App_Web_tzppu2tl.DLL' could not be foundError 2 Metadata file ...
In the following, I get a compiler warning (with VS2005 Beta 2, but not VS2003) on the Close() call. I'm using a reference to Microsoft Word 9.0 Object Library. Word.ApplicationClass WordApp = new Word.ApplicationClass();object missing = System.Reflection.Missing.Value;Word.Document aDoc = ...
Hello, I am trying do set up a multicast delegate to split my yield returns for a WebTest I am writing, but only the last delegate is firing. Is this a known problem, by design, or am I doing something wrong? Thank you, --ben
This code example from help doesnt work; Msg is called every time. AND, the web page editor to post this code also fails, with this messagebox:Line 188Char 1Error: '_ctl0_Maincontent__ctl0_PostForm_PostBodyRichText_Toolba...' is undefinedCode 0Url .../AddPost.aspx?ForumID=59 // ...
What constitutes acceptable posts to these ngs? Is it acceptable to point out problems with the products?
When multiplying very large Int64 numbers, I've noticed some strange results.For example, in C# .NET: Int64 lngNumber; lngNumber = 4611686018427387904; lngNumber = lngNumber*2; Console.WriteLine(lngNumber.ToString());Outputs -9223372036854775808Changing the multiplier to 3 as follows: Int64 ...
For example, there are three C# project in my solution, and I want to synchronize their version. What I have to do now is to manually edit "AssemblyInfo.cs" file in every project. If there were a way to "include" a C# file, put information common to all projects in that file, it would be much ...
This code example from help doesnt work; Msg is called every time. AND, the web page editor to post this code also fails, with this messagebox:Line 188Char 1Error: '_ctl0_Maincontent__ctl0_PostForm_PostBodyRichText_Toolba...' is undefinedCode 0Url .../AddPost.aspx?ForumID=59 // ...
787 byte By
jan_hk at 2008-2-14
I received a DLL which uses BSTR as string type:example : given in the include file DLLEXPORT BSTR WINAPI I2cGetInterfaceTypeStr (BSTR Interface);how do i access this function in vc#. This doesn't work.[DllImport("I2CAPI32.dll")] public static extern string I2cGetInterfaceTypeStr (string ...
342 byte By
folen at 2008-2-13
am writing a math toolabr i need the "for all symbol" (fliped A) i found it in unicode (at symbol font) but i can't make the program show it (it's shows a small []) i know how ("\uF022".ToString) but it still dosn't show i think i need to change the font or add font but ms word dos and i ...
Hi,I've been searching the MSDN docs, Googling around and trying to search these forums, but yet have to find an answer to my question.How do you reference a generic class using XML documentation? Obviously, <see cref="System.Collections.Generic.List<T>"/> doesn't work. I tried ...
I am having some problems understanding how to use interfaces within the generic collection framework. I expected the code below to work. public interface Reader { string GetValue(); } public interface ReadWriter : Reader { void SetValue(string value); } public class MyReadWriter : ReadWriter ...
161 byte By
suguna at 2008-2-12
When i am trying to login module it accepts whatever i am entering in the user name. IN ORDER TO RESTRICT THIS I WANT TO COMPARE WITH TEXTBOX WITH DATABASE FIELD
Hello, and first of anything please forgive me if my question is very basic, i'm new to the c# programming, and to programming also, and i'm reading inside c# book, but i dont understand:what is the objective of the boxing and unboxing methods, and what are the differences between have a ...
In the Help there is no information on Direct X? How to me to receive the necessary information?
How can I remove all the method calls off the stack of an object in C#?I set the variable equal to null but the object is still executing the code.For example if I have onc class calling a method of the other and that calling other methods in that class like this:class A{ private B var; void ...
After recompiling the following code with VS 2005 Beta 2, an C# assembly can't calling the indexer. The code sample works fine with VS 2003. //C++:[System::Reflection::DefaultMember("Parameter")]public __gc class NativeObjectConfigurator : public System::Collections::ArrayList{public: ...
I'm new to C# and NUnits. Can anyone point me in the right direction as to how I can create a loop that passes each and every unicode character of each set one at a time to an api that I'm testing? It seems like the Unicode set are enumorated. Is it possible to use a for each character set ...
1168 byte By
dba at 2008-2-7
I'd like to write methods that perform arithmetic operations on generic (but numeric) parameters.The following code produces compiler error CS0019 public T Add<T> (T a, T b) { return a + b;} while this produces compiler error CS0072 public T Add<T> (T a, T b) where T:ValueType{ ...
1002 byte By
anemvr at 2008-2-7
Hi All,I am using Visual Studio .Net 2003.I am working on Web applications using ASP.Net.In UI design, I have textbox for username and password field, say txtUserName, txtPassword. And also UI Contains one combobox for business entity say cmbBusinessEntity.Following properties are set for above ...
201 byte By
naveen at 2008-2-7
Hi, By default the backroung of treeview control is white...I want to change it to other color Is there a way that we can change the backround color of treeview control(compact frame work 2.0)
I have a exceptionBase class for application level exception and one data tire baseclass.Now I want to create a class which will inherit both the above base classes.How can I approach thsi?I am using abstract base classes...Please suggets me some guide ...
I have a exceptionBase class for application level exception and one data tire baseclass.Now I want to create a class which will inherit both the above base classes.How can I approach thsi?I am using abstract base classes...Please suggets me some guide ...
Hello,a former c++ dev in my team is a bit worried by the following code which implies inheriting interfaces, and having inheriting implementations as well.public interface IMyInterface{ /* */}public interface IMyChildInterface : IMyInterface{ /* */}public class MyImpl : IMyInterface{ /* ...
I'm getting a compiler warning with the following code:foo = someOperation();lock( foo ){ ... internalmethod( ref foo ); ...} The warning is:file.cs (3,1): warning CS0728: Possibly incorrect assignment to local 'foo' which is the argument to a using or lock statement. The Dispose call or ...
I am trying remove the extra " " marks between the string which is in already in " ". The string is in following format "Where are you,"can you help me", please."So i need to remove the middle quotation marks from the string and return the total string.the out...
In generic approach I can use default keyword to know what is default valuepublic T GetDefaultValue<T>(){ return default(T);}But if only has a System.Type, I can't use default keyword to do it....public object GetDefaultValue(System.Type dataType){ return default(dataType); //Not ...
K, after an hour or so of playing with generics I've already hit my first snag... How do you declare an abstract property to return an instance of a template class that will be instantiated with the type of the derived class (what a mouthful!)? i.e.: public abstract class Node { public ...
In language Visual C# 2003 there was a function Pass, in a class Microsoft.DirectX.Direct3D.Effect, and in language Visual C# 2005 this function is absent, what function replaces this function?
I tried the following without success. I don't want to have to code a separate method just so I can pass the setter function to another class as I'm going to be doing this a lot.public class MyClass{ public delegate void SetStringDelegate( string value); public string MyProperty { get{ return ...
Hi I want to explore my skills in c# class factory design pattern . Please help me and provide some free resources. best regards ashok kumar roy
How to translate files created in 3ds max in a format X?