|
If you're using .NET 2.0, use a List instead and provide a sorting function. I can't recall, but I thought you can do this in 1.1 and 1.0 as well, probably just with lots of casting of objects.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Christian Graus wrote: I thought you can do this in 1.1 and 1.0 as well, probably just with lots of casting of objects.
Yup, for sorting operation there must be operators <, >,= defined (or some of them at least), which System.object does not have.
"Throughout human history, we have been dependent on machines to survive. Fate, it seems, is not without a sense of irony. " - Morpheus
"Real men use mspaint for writing code and notepad for designing graphics." - Anna-Jayne Metcalfe
|
|
|
|
|
Hello,
Saikek wrote: The sorting field is A.
I don't understand this!
Don't you mean you whant to sort your Collection of "A"-class instances, with the value of the "A"-class member "a" (which is an int)?
Martin
|
|
|
|
|
As others said, if you are using .NET 2.0 use generic collection (List<A> ). As for sorting, you probably mean sorting by field int 'a'? As you dont expose anything (a,b is private) you could implement IComparable . Or if you can expose sorting field, custom implementation of IComparer that knows how to sort class A (e.g. A.SortByFieldAComparer). Look up appropriate interfaces in MSDN or google.
"Throughout human history, we have been dependent on machines to survive. Fate, it seems, is not without a sense of irony. " - Morpheus
"Real men use mspaint for writing code and notepad for designing graphics." - Anna-Jayne Metcalfe
|
|
|
|
|
Hello,
Just because I'm curious:
Do you know of a equivalent Comparer class to System.Collection.CaseInsensitiveComparer, which comparse int values?
Or is the solution to use "ToString" for comparison.
dnh wrote: As for sorting, you probably mean sorting by field int 'a'?
I'm happy that it's not only me, who thinks that the question is not valid.
All the best,
Martin
|
|
|
|
|
Hmm, there is only one way how to compare integers (that makes sense) as far as I know. System.Int32 implements IComparable , so no need for comparer.
"Throughout human history, we have been dependent on machines to survive. Fate, it seems, is not without a sense of irony. " - Morpheus
"Real men use mspaint for writing code and notepad for designing graphics." - Anna-Jayne Metcalfe
|
|
|
|
|
Hello dnh,
2 minutes after I posted this yesterday, I hoped you would ignore it.
So the .Net 1.1 solution for me would be, use the Sort method of the ArrayList class and give a user specific IComparer instance as parameter.
Userspecific IComparer instance would be something like this:
public class ComparerForIntMemberaInClassA : IComparer
{
int System.Collections.IComparer.Compare( object x, object y )
{
A firstA = x as A;
A secondA = y as A;
return firstA.a.CompareTo(secondA.a);
}
}
What's your feeling about it?
Thank you for you interest!
All the best,
Martin
|
|
|
|
|
yes, that looks fine. Other solution would be implement IComparable in class A; I don't know the guidelines but to me it feels like for "default" sorting I would implement IComparable in class I want to sort (if it is class I own - if it is e.g .NET framework class then I can't do that) and non standard comparations (e.g case insensitive) would go into custom comparers. If you are sorting by private members, nested class should solve access problem.
"Throughout human history, we have been dependent on machines to survive. Fate, it seems, is not without a sense of irony. " - Morpheus
"Real men use mspaint for writing code and notepad for designing graphics." - Anna-Jayne Metcalfe
|
|
|
|
|
Thanks for your statement!
Have a nice day!
All the best,
Martin
|
|
|
|
|
hi all,
i've developed a windows application , i wanna add update software feature to it,[i mean my client should be able to update the softawere 1.0.0 to 2.0.0]
can u please tell/suggst me how to/accomplish this
prashanth,
s/w Engineer,
Syfnosys.
|
|
|
|
|
ClickOnce is part of VS2005 and does this.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
hi
i found Clickonce is very good, and tried alot to understand,
see could able to publish and make the new versions,
but my requirement is whenver user opens my applicaions and connected to internet i need to promt him saying u r working with olderversio(1.0 and current version 3.0 is available)
if user clicks ok it should be updated please
help me how to do so
thnx in advance
prashanth,
s/w Engineer,
Syfnosys.
|
|
|
|
|
|
Hi,
My name is srinivasan and I am new to this DTS concept.
I have to execute the DTS package from the C#.Net Code behind.
I managed to create a small DTS Package in SQL server and execute it from SQL Server Enterprise Manager.
But I can not execute that Package from C#.Net.
Can any one help?
I’ve written a small Class for Executing the DTS but it's not working.
CLASS: Class1
Function: DtsPackage()
---------------------------------------
public void DtsPackage()
{
try
{
Package2Class Package = new Package2Class();
object pVarPersistStgOfHost = null;
Package.LoadFromSQLServer
("<server name>","<user name>","<password>",DTSSQLServerStorageFlags.DTSSQLStgFlag_UseTrustedConnection,"","","","Test Package",ref pVarPersistStgOfHost);
Package.Execute();
Package.UnInitialize();
System.Runtime.InteropServices.Marshal.ReleaseComObject(Package);
Package = null;
}
--------------------------------------------------
And when I execute this I am getting an error.
__________________________________________________________________
ERROR:
Login failed for user '(null)'. Reason: Not associated with a trusted SQL Server connection.
__________________________________________________________________
What could be the reason?
The 'server name', 'user name' and the 'password' was also correct.
Server name is SQL Server's Name.
User Name is SQL Server's User Name.
Password is SQL Server's Password.
Thank you in advance,
Seenu.
-- modified at 6:41 Wednesday 4th April, 2007
SrinivasanPrabakaran.
Trainee Software Engineer.
Metrica Systems.
Bangalore.
|
|
|
|
|
Sir/Madam,
Can somebody please provide the help with the help of an easy example how to differentiate between
Protected
Internal
Internal protected
Please help.
Thanks and regards
Pankaj Garg
|
|
|
|
|
Protected means that only derived classes can see it
internal means that only classes inside the current assembly can see it.
Protected Internal would mean that only derived classes within this assembly can see it.
'Problem' is not a very useful header.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Sir,
Sorry for the irrelevant header.
Next time i will take care for it.
Can u please explain with example the difference b/w internal and internal protected.
Thanks and regards
Panakj
|
|
|
|
|
internal:
Access is limited to the current assembly.
protected internal:
Access is limited to the current assembly or types derived from the containing class.
Regards,
Satips.
|
|
|
|
|
Hi,
Here an example.
U have 2 dlls : DLL1 and DLL2.
In DLL1 u have a class Employee with a method Fire()
In DLL2 u have a class Boss.
1- if u declare the Fire method as protected, in the boss class u can invoke the Fire method and U cannot invoke the fire method anywhere else the Boss class
2- if u declare it as Internal : u can invoke the fire method anywhere in DLL1 but not in DLL2. U cannot also view the method in the Boss class (because it's in the DLL2)
3- If u declare it as Internal protected, u can only invoke the method from a class inheriting from Employee located in the DLL1.
HTH.
Hayder Marzouk
|
|
|
|
|
Hi all,
I am trying to add .dll file as a reference in my C#.NET application but i am getting error i.e.
A reference to 'C:\STAF\bin\STAF.dll could not be added. Please make sure that the file is accessible, and that it is a valid assembly or COM component.
Is there any other way out to add dll into C# or no. Because what i am doing is
Project->Add Reference->Browse->*.dll
Thanks
|
|
|
|
|
Sounds like it's not a .NET dll, and not a COM dll. You can call it's methods via pinvoke.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
I have to add multiples into a dataset. Using this dataset i am creating a crystalreport. How to add the tables into a dataset. I am getting error in the report.
the code is as follows...
string strConn = "data source=HP10503715219;persist security info=False;initial catalog=MOHAM;pwd=sa;user id=sa";
SqlConnection sqlConn = new SqlConnection(strConn);
DataSet ds = new DataSet();
strCmd = select cm.name, om.oclientref, pm.productname, om.orcvddatetime, od.opastatecode, cu.countyname, om.ordercost, om.additionalcost,om.total,om.subclient from ordermain om, orderdetail od, clientmaster cm, countyusa cu, productmaster pm where cm.clientid = om.oclientid and pm.productid = om.oproductid and cu.countycode = od.opacountycode and om.oslno = od.oslno and (om.ostatus='Completed' or om.ostatus='sent to client');
SqlDataAdapter da = new SqlDataAdapter(strCmd, sqlConn);
da.Fill(ds);
ds.Tables[0].TableName = "ordermain";
ds.Tables[1].TableName = "productmaster";
ds.Tables[2].TableName = "clientmaster";
ds.Tables[3].TableName = "countyusa";
ds.Tables[4].TableName = "orderdetail";
sqlConn.Close();
CrystalReportViewer1.DisplayGroupTree = false;
CrystalReportViewer1.HasCrystalLogo = false;
myReportDocument.Load(Server.MapPath("Total.rpt"));
myReportDocument.SetDataSource(ds);
CrystalReportViewer1.ReportSource = myReportDocument;
CrystalReportViewer1.DataBind();
ERROR: System.IndexOutOfRangeException: Cannot find table1
thanx in advance
yamini
|
|
|
|
|
According to ur select query u r selecting data from five different tables
which is coming to one table in dataset.so ur data set contains only one table
and u r trying to set table name property of more than one table that is why u r getting this error so remove following lines from ur codes.
ds.Tables[1].TableName = "productmaster";
ds.Tables[2].TableName = "clientmaster";
ds.Tables[3].TableName = "countyusa";
ds.Tables[4].TableName = "orderdetail";
rahul
|
|
|
|
|
If i remove from there , then how and where shall i include the table names to the dataset.
yamini
|
|
|
|
|
As i have explained that ur dataset contains only one table so u can give name to this table only like
ds.Tables[0].TableName = "XYZ";
rahul
|
|
|
|