|
No, they are not the same.
DenClancy wrote: Triangle[] copy = new Triangle[triangles.Length];
for (int i = 0; i != copy.Length; i++)
{
copy[i] = triangles[i];
}
This will give you a new array, but it contains references to the same objects as the original array.
DenClancy wrote: Triangle[] copy = triangles;
This will only give you another reference to the same array.
---
single minded; short sighted; long gone;
|
|
|
|
|
Hi,
I am using Windows Indexing services via the OleDB Driver.
Now everything works good, till i am to pass (") double quotes into the query
Sample query to pass
SELECT path FROM SCOPE() WHERE Matches("test*");
Now after all the process the VS 2005 just appends \ to my query
SELECT path FROM SCOPE() WHERE Matches(\"test*\");
"Mess with the Best, Die like the rest"
|
|
|
|
|
Passing queries is a real bad idea to being with because of sql injection issues. Still to fix your problems you just need more double quotes. I believe your query will work if it is like this:
SELECT path FROM SCOPE() WHERE Matches("""test*""");
Hope that helps.
Ben
|
|
|
|
|
Thx for the replying
Below is the original c# code
queryString = queryString + " MATCHES(""" + strExactPhrase.ToString() + """)";
* *
*'s are the points where i am getting an error "; expected" in VS 2005
Thank you!
"Mess with the Best, Die like the rest"
|
|
|
|
|
Does this work:
queryString = queryString + " MATCHES(\"" + strExactPhrase.ToString() + "\")";
Ben
|
|
|
|
|
I think you're mixing up C# and VB.NET here. VB.NET uses pairs of quotes ("" -> "), while C# uses backslash-escapes (\" -> "). If you print the string to the debugger or watch windows, you WILL see the escape codes in C#, but that's not actually in the string.
So basically, stick with the original version, using \" to represent a double-quote, and don't worry if you see the backslash when debugging.
|
|
|
|
|
You are right. You know I think I might have also gotten it mixed up with the single quote. You can have problems with that as well.
Ben
|
|
|
|
|
The single quote shouldn't cause you any problems in C#, since it has no special meaning inside double-quotes. That's only used to signify a character instead of a string.
|
|
|
|
|
Really, try a query that searches for a lastname of o'leary. You can certainly have some problems with that. I have had more problems with this because of some dynamic sql creation. I have some stored procedures where you pass in some xml that is a parameter list. The xml is read into a table and then those parameters are used to dynamically create a specific seach query. In that case you for sure can have problems passing in single quotes.
Ben
|
|
|
|
|
Ah, well that has to be a problem with the SQL provider, not with C#... C# will happily pass single-quotes into a string, but maybe the data source has trouble parsing it out.
|
|
|
|
|
Right, I am sorry if I was saying .net would have a problem. The problem is on the sql server side.
Ben
|
|
|
|
|
Thx a lot
The thing got resolved, it was the OleDB Data Provider's dll that needed to be re-installed
Thank you!
"Mess with the Best, Die like the rest"
|
|
|
|
|
Hello everyone,
I ran into this error, which im not sure whats wrong.
On my form1.cs, i have this code:
SyntaxHighlightingTextBox shtb;<br />
public form1<br />
{<br />
InitializeComponent();<br />
shtb = new SyntaxHighlightingTextBox();<br />
shtb.ContextMenu = MyContextMenu;<br />
}
When i try to build the solution, i get the following error:
Cannot implicitly convert type 'System.Windows.Forms.ContextMenuStrip' to 'System.Windows.Forms.ContextMenu'
I don't understand, i have a fully working context menu, but when i try to add that context menu inside shtb (SyntaxHighlighting RichTextBox), im getting that error.
Anyone can help me figure this one out please?
|
|
|
|
|
Your trying to add a ContextMenuStrip when you need to be adding a ContextMenu.
Either change your ContextMenuStrip to a ContextMenu or change your SyntaxHighlightingTextBox to inherit the textbox class in the .net 2.0 framework
|
|
|
|
|
Thanks allot for your advice,
I changed
shtb.ContextMenu = MyContextMenu;
To
shtb.ContextMenuStrip = MyContextMenu;
Now its working
|
|
|
|
|
DataView defaultView = new DataView();
//this table has three fields...
defaultView = dsCorrelationsIndices.Tables["CorrelationsIndicesValues"].DefaultView;
//one row is returned...
defaultView.RowFilter = dsCorrelationsIndices.Tables["CorrelationsIndicesValues"].Columns["Index1Name"].ColumnName + " = '" + strIndex1Name + "' AND " + dsCorrelationsIndices.Tables["CorrelationsIndicesValues"].Columns["Index2Name"].ColumnName + " = '" + strIndex1Name + "'";
I would like to get the value in the third column
//?????????????????
string v = how do I get the third value from the filtered dataset??
Thanks
|
|
|
|
|
defaultView[rowNumber][2].ToString();
or
defaultView[rowNumber]["ColumnName"].ToString();
|
|
|
|
|
Hi,
This ia quite an urgent problem I have here, my project is slipping too far and I have a racing festival to launch my code for very soon so any help would be appreciated!
I have the following code, which is broken down into a more managable form, during the debugging process:
1: object o=new MembershipLevel().FindByItemCode(itemCode);
2: MembershipLevel membershipLevel=o as MembershipLevel;
Now, line 1 successfully extracts a record from the database and populates o accrdingly, with a MembershipLevel object. It's great, I can see it's the correct record, and it is the correct type.
Line 2 is used to cast the type into something so I can get at the data inside it. However, this cast fails. In its original shorthand form of { MembershipLevel membershipLevel=(MembershipLevel)o }, this threw an exception InvalidCast excpetion saying "Cannot cast MembershipLevel into MembershipLevel", so it knows the types are same, but it will not cast it!
MembershipLevel has been loaded via reflection from the web site bin folder. Interestingly, a previous object has also been loaded using the same method and that works fine. Also, this code is in the same assembly. The assembly is present and correct.
Any help appreciated
|
|
|
|
|
My best guess would be that you have two classes with the same name, but in different namespaces. After step 1, try comparing the following two statements, and see if they match:
o.GetType().ToString()
typeof(MembershipLevel).ToString()
Alternatively, it might be the same type, but a different signature. You said you're loading it through reflection, so the file you're loading might have an older version of "MembershipLevel". If the signatures don't match, you can't cast it.
|
|
|
|
|
Thanks for your reply.
The namespaces are identical, I removed them from the code I posted for clarity. (They are quite deep and had company names in)
For your second point, this does seem likely, but I am quite sure it is loading and debugging from the same assembly. I can cast fine in the debugger immediate window, just not in the code. The file is in the bin folder in the web site, where else could it be getting the class? It is in a class library.
HOw can I tell? Particularly if the debugger casting works fine?
|
|
|
|
|
Hmm, it works in the debugger but not in the code itself?
I'm running out of ideas here. There might be some quirk with ASP, which I'm not very familiar with. My best guess is still a duplicate class name. The debugger might be resolving it differently, so try outputting the type name in the code just to be sure.
Other than that, I really can't tell you much without knowing more about the code.
|
|
|
|
|
If you are doing this in ASP, then you might have an older definition of the class sitting around in the IIS compile cache. You may have to try clearing that out and see if it helps. I've had these issues before....and it always is something that I've done or another developer has done. In one case, my test class worked perfectly. But it turned out a web developer created reference to a hard dll location instead of Project Output and the ASP code was executing my code to get the object then using the old reference in the web app for casting. Grrrrrr.
Unfortunately, this is not something that is quick to fix if your solution is huge. Clean out the solution, make sure the dll isn't in any bin or obj folder, make sure there is only a single instance of pubic class ObjectType (sorry I forgot the object name you were erring out on) by doing a solution level Find and also by doing a file-level search with a search string.
I cannot find on my machine where ASP.NET caches the compiles. Maybe someone else here can help.
|
|
|
|
|
Oops, I replied with this info to the wrong person. If you're running in ASP or not -- here are some things to consider.
If you are doing this in ASP, then you might have an older definition of the class sitting around in the IIS compile cache. You may have to try clearing that out and see if it helps. I've had these issues before....and it always is something that I've done or another developer has done. In one case, my test class worked perfectly. But it turned out a web developer created reference to a hard dll location instead of Project Output and the ASP code was executing my code to get the object then using the old reference in the web app for casting. Grrrrrr.
Unfortunately, this is not something that is quick to fix if your solution is huge. Clean out the solution, make sure the dll isn't in any bin or obj folder, make sure there is only a single instance of pubic class ObjectType (sorry I forgot the object name you were erring out on) by doing a solution level Find and also by doing a file-level search with a search string.
I cannot find on my machine where ASP.NET caches the compiles. Maybe someone else here can help.
|
|
|
|
|
Thanks for all your help, guys.
I'm at home now, but I will certainly apply your ideas tomorrow. I have tried many of them, I'm afraid!
Your right, my solution is huge, and that is why it is difficult for me to post more code, because it would complicate the whole thing.
If I'm right, the code cache is in /Windows/Microsoft.NET/Framework/v2.0.5727/Temporary ASP.NET Files ... and I cleared this folder out after recycling IIS.
Still doesn't work.
I will try and delete all instances of the DLL on the machine, as you suggested, and try it.
|
|
|
|
|
Hi all.
Thanks for your help for this so far.
I have tried your suggestions, including:
* Purging all traces of the DLL and rebuilding
* Verifying this is the same class by searching for other classes
With no success.
I have output some extra debug info:
CodeBase of o is file:///C:/Inetpub/Sitecore53SandPit/WebSite/bin/Duke.IomTT.TTLive.DLL, v0.1.0.18554
CodeBase of MembershipLevel is file:///C:/Inetpub/Sitecore53SandPit/WebSite/bin/Duke.IomTT.TTLive.dll, v0.1.0.18554
So, even though it is the same class, and I can see inside the object in the debugger, has the same data - I cannot cast it.
Really stuck!
|
|
|
|