|
|
The original question was something like - why can't I do this
class SomeClass
{
void SomeMethod()
{ }
static void SomeMethod()
{ }
} The original question was more succinctly put, with reasoning behind why the OP thought it should be allowed
Dave
BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn) Why are you using VB6? Do you hate yourself? (Christian Graus)
|
|
|
|
|
a new twist to the old forums?
|
|
|
|
|
Luc Pattyn wrote: a new twist to the old forums?
I'm still not sure about the current 'new twist[^]'
Dave
BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn) Why are you using VB6? Do you hate yourself? (Christian Graus)
|
|
|
|
|
Dear All
How can i create menu or toolbar in windows native look in .net
Usually its look different from normal menu and toolbar of windows
also how to use rebars in .net
Thanks and Regrads
Radhakrishnan G.
|
|
|
|
|
I'm using mysql database..I have forms setup main form has datagrid..you can add to this datagrid and save to datbase with my add form and it works fine. I can delete from the datagrid and it works fine...when I select an account to edit is when I have my issue...form edit brings up the selected account but when I save my changes it doesn't save to the selected account it changes my first account in the database...Help...here is a sample of my code
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSave.Click
' 'Save changes to database and exit
Dim intResponse As String
intResponse = MsgBox("Do you want to SAVE Changes to this record?", vbOKCancel, "Save?")
If intResponse = vbOK Then
PbCustomerDS.customer(0).Address_Line1 = Address_Line1TextBox.Text
PbCustomerDS.customer(0).Location = LocationTextBox.Text
PbCustomerDS.customer(0).Attention = AttentionTextBox.Text
PbCustomerDS.customer(0).City = CityTextBox.Text
PbCustomerDS.customer(0).State = StateTextBox.Text
PbCustomerDS.customer(0).Zip = ZipTextBox.Text
PbCustomerDS.customer(0).Phone = PhoneMaskedTextBox.Text
PbCustomerDS.customer(0).Bill_To = Bill_ToTextBox.Text
PbCustomerDS.customer(0).Attention_2 = Attention_2TextBox.Text
PbCustomerDS.customer(0).B_address = B_addressTextBox.Text
PbCustomerDS.customer(0).B_City = (B_CityTextBox.Text)
PbCustomerDS.customer(0).B_State = B_StateTextBox.Text
PbCustomerDS.customer(0).B_Zip = B_ZipTextBox.Text
PbCustomerDS.customer(0).B_Phone = B_PhoneMaskedTextBox.Text
PbCustomerDS.customer(0).Comments = CommentsTextBox.Text
PbCustomerDS.customer(0).Updated = UpdatedLabel1.Text
Me.Validate()
Me.CustomerBindingSource.DataSource.GetType()
Me.CustomerBindingSource.EndEdit()
Me.CustomerTableAdapter.Update(PbCustomerDS)
Me.TableAdapterManager.UpdateAll(PbCustomerDS)
Me.Close()
End If
If vbCancel Then
Exit Sub
End If
End Sub
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
can someone please help me with my issue?
|
|
|
|
|
Hi
I want to apply membership authentication in my asp.net application(c#).
I want to keep the membership information in my existing database. Is there any one who can help me for this?
Regards
MG
|
|
|
|
|
I think this can help you to start [^]
|
|
|
|
|
I need to use the following regular expression from an undocumented sources
<snippet(?<id>\w+)>.*\n(?<tx>(.|\n)*?)\n.*</snippet(\k<id>)>
Can anyone help with a sample region matched by this expression? I have being trying some without success.
Best regards,
Paul.
Jesus Christ is LOVE! Please tell somebody.
|
|
|
|
|
Here's a sample:
<br />
<snippetqwer>123<br />
fgfg<br />
sggfbsgbgb<br />
</snippetqwer><br />
The Regulator is a great tool for regexps, consider using it
|
|
|
|
|
Thanks so much for the reply. This is the valid sample.
This seems to be a bug, though - thanks for helping me sought this out.
The original system expected format "eID#sID" (where eID is example ID, and sID is snippet ID) for the "qwer" you used, so I thought the new is also expected in that format.
I will take a look at the regulator, I am currently trying, Expresso, http://www.ultrapico.com/Expresso.htm[^]
Now, I know where the problem is. Again, thanks for the great help.
Best regards,
Paul.
Jesus Christ is LOVE! Please tell somebody.
|
|
|
|
|
I'm confused.... If I have two different hash-sets with identical values they yield different hash codes?
static void Main(string[] args)
{
HashSet<int> setA = new HashSet<int>(new int[] { 1, 5, 10 });
HashSet<int> setB = new HashSet<int>(new int[] { 1, 5, 10 });
Console.WriteLine("Hashcode A = "+setA.GetHashCode());
Console.WriteLine("Hashcode B = "+setB.GetHashCode());
}
Actually the hash codes returned are the same whatever values I have in the sets (only sequence of creation matters - is the hash code based on the address of the values?). I thought a good hash function should yield the same return value with the same values - any advice what I'm overlooking?
|
|
|
|
|
Each object has a hash code, that must depend on at least one of its instance values. your setA and setB are two different objects (similar content, but unrelated objects), hence they are allowed to have unrelated hash values.
Also hash values are mainly useful for objects INSIDE collections, not for collections themselves.
See the documentation[^], in particular the remarks and the "Notes to Implementers".
|
|
|
|
|
Thanks a lot for the feedback (reminds my: "If everything else fails read the manual"...)
So I think I'll have to overwrite GetHashCode for HashSet to yield the same values when contents are the same (I'm looking for testing equality between sets and SetEquals doesn't do the job as I apparently have to live with default Comparer for that ).
|
|
|
|
|
ThomasPep wrote: If everything else fails read the manual
Better yet: before you use some class/method, read the manual. When it fails, read it again.
|
|
|
|
|
Did you try creating the hash sets with the comparer you want to use? It appears that if both hash sets are using the same comparer, that comparer should be used from SetEquals.
|
|
|
|
|
I had a HashSet of HashSets - and wanted no duplicates when the elements (the sets) contained the same values. I did succeed (finally) by creating the sets with a non default comparer and SetEquals as you write (and overwriting all "GetHashCode" I could think of potentially being called ).
It seems to me that the HashSet implementation in .net needs some twisting to work with references/nested references when testing on values is needed (I didn't succeed with CreateSetComparer as only "1-level", though should be possible to nest this).
The following also confused me good during debugging:
using System;
using System.Collections.Generic;
HashSet<HashSet<int>> setA = new .....;
HashSet<int> subSetB = new HashSet<int>(new int[]{....});
setA.Contains(subSetB)
This code ran well except I could never find subSetB... - and I was confused (happens a lot to me) as the documentation referred to two methods including one setA.Contains(subSetB,myComparer) which I couldn't find with IntelliSense.
Finally I realized that the namespace for the two methods were System.Linq, so I included System.Linq and I could use myComparer and find subSetB. I guess the code above used an earlier version of HashSet than .NET 3.5 to run - but that took some time to find out.
modified on Thursday, December 31, 2009 12:53 PM
|
|
|
|
|
Hi all,
Hopefully this is the right thread for this question. I was quite uncertain to whether it was a .NET question or a C# question. However, I could see more thread related questions under the c# subject.
Well, I am new to the c# and the .net platform. I wonder if some kind soul could help me with my question. I am trying to develop a monitoring application that will be able to monitor all servers and Oracle databases on a network. I am using SQLITE for the local database and perl to act as the agent that keeps checking things out. For the front end, (The Configuration Assistant tool) I am using C#.
I often need to connect to Oracle Databases from my UI thread. I am avoiding to lock the UI by executing the DML under a second thread as follows:
try
{
foreach (ListViewItem monitoredDatabases in monitoredDatabasesListView.Items)
}
String[] connectionResults = new String[10];
Thread testOracleConnection = new Thread(delegate()
try
{
}
catch (OracleException)
{
throw;
}
});
testOracleConnection.Start();
while (testOracleConnection.IsAlive)
{
Application.DoEvents();
Thread.Sleep(1);
}
}
catch (Exception) CATCH on thread 0
{
progressInfoForm.Close();
Cursor = Cursors.Default;
return (false);
}
As you can see on the above code, the exception never gets to the CATCH statement on thread 0 and causes the entire application to crash.
What I want to do here is have one single place to restore all the normal behaviour of the form once it has encountered an exception. Eg, within the CATCH statement of the thread 0 (UI), I then reset the Cursor style, close the progress bar form and return with the correct status to the calling method.
It would be great if someone could actually show me how I could solve this problem by changing the code snipped above so that I can try it out and definitelly understand the solution.
Thank you very much.
Daniel
|
|
|
|
|
See:
Proper Threading in Winforms .NET[^]
If this doesn't help you solve the problem let us know.
Also do some research on:
AppDomain has an UnhandledException
Application has a ThreadException
Using these you will have the ability to catch any exception before it blows up the application. It's caught in the 'Main' Class of you application.
~TheArch
|
|
|
|
|
hi daniel,
I've read your code and performed following test. looks you can not just throw your exception in the new thread. you can handle it in the worker thread and use delegate to process it in GUI thread.
The following is my test code. 2 buttons in one single form. "Button1" can cause the program crash. "Button2" success capture the error. Hope it helps.
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
Thread t = new Thread(delegate()
{
DoWork();
});
try
{
t.Start();
}
catch (Exception ex)
{
commonExceptionHandler(ex);
}
}
private void button2_Click(object sender, EventArgs e)
{
Thread t = new Thread(delegate()
{
try
{
DoWork();
}
catch (Exception ex)
{
commonExceptionHandler(ex);
}
});
t.Start();
}
private void commonExceptionHandler(Exception ex)
{
if (this.InvokeRequired)
{
this.Invoke(new Action(() => commonExceptionHandler(ex)));
}
else
{
MessageBox.Show("[got it!] "+Environment.NewLine+ ex.ToString());
}
}
private void DoWork()
{
throw new InvalidOperationException("this is test");
}
}
|
|
|
|
|
Since you are running this from a UI form, I would use a BackgroundWorker. This allows you to trap an event when the BackgroundWorker ends, and you can tell whether it completed normally, or whether it failed with an exception and if so what exception it received.
|
|
|
|
|
Hi experts,
The easiest way to send email .net for smtp clients is using System.Net.Mail Smtpclient. But I would like to send it through ma proxy server which has IP as 192.168.0.1. Is there any way in .net.
Please let me know how I will be able to send emails from proxy. I have found lot of apps which provide the mechanism to do so. But I don't like to purchase like to make my own.
Thanks & Best Regards
Jay Khatri
|
|
|
|
|
The SMTPClient class does not support using a proxy. You'll either have to write your own implementation of SMTPClient that does support it, or find a 3rd party library that does.
|
|
|
|
|
Hello there,
I am creating a web application and i need to communicate with a server(Mainly it is a mail server). But i want an general answer how could i communicate with these servers??Such as opening connection retrieving data and closing connection
|
|
|
|
|
khKamel wrote: general answer
One way to communicate between machines is by using a socket.
There are only 10 types of people in this world — those who understand binary, and those who don't. |
|
|
|
|