I have used
list<>
data type to store emp id. As
List<int> EmpIds = new List<int>() ;
But it takes duplicate entries. Which data structure I should use to have collection of unique ids.
I have used
list<>
data type to store emp id. As
List<int> EmpIds = new List<int>() ;
But it takes duplicate entries. Which data structure I should use to have collection of unique ids.
I have created a collection class which has below methods
Class EmPInfo
{
Count()
Add (Struct classinfo)
Item()
Sort()
}
This class uses List<> object ,which holdes Emp class obj. Add method internally craetes a EMP class object and stores that data in a list object. Sort function perform sorting using some information set by the user. Please suggest the correct way of creating a colletion class in .Net.
public List<string> GetList()
{
List<string> list = new List<string>();
return list;
}
But as per msdn we should not expose the generic list. How to return a list from a method. 2) Simillarly I have a method which has dictionary as a return type How to return a dictionary from a method. 3) In my code I have craeted a dictionary as
Dictionary < int , Some Str>
. Now I need a colletion of keys avaialble in the dictionary. How to do this.?? Do I need to retrive one by on from dictionary. ??
I am new to .Net , I have developed an application using C#.I want check the code quality of my application .Can any one suggest any tool ,which perform code quality check?
In the code how can we check for below errors i) DB files not available ii) DB is corrupted iii) Driver errors.
Thnx.. As shown in the example dataset contain data table information. Now i need to retrieve some set of data from dataset. How to do it. Can we fire quire on the data available in the dataset.
I am working on an application where i need to retrieve data (using query) from a Access database.(ABC.mdb) Please provide code snippet for this. it is helpful if you can provide sample which uses dataset .
SortList require a unique key value and in our case name can be duplicate.
I am working on an application where I have created a class emp which has ID and Name as a property. Now I want to create a collection of Emp class , which should be sorted based on the either ID or Name. (Program will decide whether it want to data sorted based on the Name or Id at the runtime). For and employ ID and NAMe property is not unique. It is possible that employed is having similar name. Can you please help me to decide which .net collection object should be used to achieve above functionality? If possible please provide a snippet. public class Emp { private int myID; public int ID { get { return myID; } set { myID = value; } } private string myName; public string Name { get { return myName; } set { myName = value; } } }
I am working on an application where I am using C# .net as well as ATL COM. I have created below classes 1) Class Add, Which is created using C# .Net. And which implement Addition functionality. This class uses IAdd interface which is having Add method to perform addition. (Please note that IAdd is an com interface and we have used it by creating interop dll)
public class Add : IAdd
{
#region IAdd Members
void IAdd.Add(double P1, double P2)
{
throw new Exception("The method or operation is not implemented.");
}
#endregion
}
class Calculate : ICustom
{
#region ICustom Members
Add add = new Add ();
#endregion
#region ICustom Members
void ICustom.CustomQueryInterface(Guid id, ref object ptr)
{
throw new Exception("The method or operation is not implemented.");
}
#endregion
}
IDL file :
[
object,
uuid(E99CD31D-34FE-4AFF-A1E6-C438F73F685F),
dual,
nonextensible,
helpstring("ICOMClient Interface"),
pointer_default(unique)
]
interface ICOMClient : IDispatch{
\[id(1), helpstring("method PerformCalculation")\] HRESULT PerformCalculation(void);
};
[
object,
uuid(53F4B9FA-B6E7-42aa-939B-97B93010270F),
dual,
nonextensible,
helpstring("IAdd Interface"),
pointer_default(unique)
]
interface IAdd : IUnknown{
[id(1), helpstring("method Add")] HRESULT Add([in] DOUBLE P1, [in] DOUBLE P2);
};
[
object,
uuid(8C4DE0FA-6D4B-4c52-9E35
In C++ we have TrackPopupMenuEx() function to displays a shortcut menu at the specified location and tracks the selection of items on the shortcut menu. How can i track the menu item selection in C#. How can i archive similar functionality in C#. Sample application appreciated.
Hi, I am new to C# , Please suggest the approach. I have written below code . public class A { public B obj = new B(); public delegate int delegateCalculate(int i, int j); delegateCalculate dc ; public int Add(int Num1 , int Num2) { return (Num1 + Num2); } public int Sub(int Num1, int Num2) { return (Num1 - Num2); } public void Display() { dc = this.Sub; obj.Result(dc); //error } } public class B { public int Num1 = 10 ; public int Num2 = 20 ; public delegate int Calc (int i,int j); public int Result(Calc dc) { int ii = dc(Num1, Num2); return ii; } } The above code gives error for obj.Result(dc); call. Please suggest how to call Result() of class B in class A.
Hi, How can i pass a collection object as a parameter ....??? Consider below example.. Interface IMyInterface { void DisplayData(??????); } Class MyClass : IMyInterface { void IMyInterface.DisplayData(??????) { Logic to display data Display First Name , Display last name... } } ///From client. Class Client { //I have a data structure (some data container) , which saves data like <key , value> say a map... MyClass myclass = new MyClass() myclass.DisplayData( ???) } Now what should be the parameter typr ???
ok.. Let say .. Interface IMyInterface { void DisplayData(??????); } Class MyClass : IMyInterface { void IMyInterface.DisplayData(??????) { Logic to display data Display First Name , Display last name... } } ///From client. Class Client { //I have a data structure (some data container or .net collection obj) , which saves data in a<< key , value >> format .. MyClass myclass = new MyClass() myclass.DisplayData( ???) } My question is how can i pass a collection data structure as a parameter in a interface DisplayData() method ?? Can i directly pass a collection object in interface method?? (Please note that this is an interface method and can be used by other languages.)
Hi, I have created two library (COM) in C# , and i have a interface method as UpdateData() in a component. Now i need t0 pass a collection as a parameter in an interface method. How can i ac chive this. Can i pass a map object as a parameter in an interface method??
I want to use an interface method in my com class . Now this can be archive by two ways 1) by importing tlb file in idl file. ii) by including/adding .h file. Can you please explain the diff betn approach i and ii and in which scenario we should use them?
I am working in a project implemented in COM (ATL)where , my class derives from app 12-14 classes. Now while implementing the same class in C#, i am facing problem (as C# not support multiple inheritance). Can you please provide me the ways we can archive multiple inheritance in .net.
I am migrating a C++ application to .NET. In C++ ,I have an template class which uses some ATL library classes for eg. template< class T > class MyBaseClass: public IConnectionPointContainerImpl, public IPersistStorageImpl, public IPersistPropertyBagImpl, { } Now i need to use this call in my new C# .net project where my new .NET call will get derive from above MyBaseClass . Please let me know how can i archive this ??? Is this possible to use a template class which uses some ATL libraray classes directly in C# ? `chiman
I am migrating a C++ application to .NET. In C++ ,I have an template class which uses some ATL library classes for eg. template< class T > class MyBaseClass: public IConnectionPointContainerImpl, public IPersistStorageImpl, public IPersistPropertyBagImpl, { } Now i need to use this call in my new C# .net project where my new .NET call will get derive from above MyBaseClass . Please let me know how can i archive this ??? Is this possible to use a template class which uses some ATL libraray classes directly in C# ? `chiman
Thnx buddy :)