|
The problem lies in something that is not defined in this code : what is the class type for wordCounter ?
Is wordCounter a class which implements the IDictionary interface ? In this case, I think the "1" in
wordCounter.Add(strArray[i], 1); is wrong. A unique value is expected.
|
|
|
|
|
.S.Rod. wrote:
what is the class type for wordCounter ?
SortedList wordCounter = new SortedList();
Ignore my code, I started with one thing and ended up doing something else.
If the file contents is like this:
The Code Project Rocks
-
Yes It does.
-
It's Awesome.
I want all those sentences stored in the SortedList.
What's the easiest way?
Don't and drive.
|
|
|
|
|
SortedList sL = new SortedList();
sL.Add( "The Code Project Rocks", 0);
sL.Add( "Yes It does.", 0);
sL.Add( "It's Awesome", 0);
int i=0;
while ( i < sL.Count )
{
MessageBox.Show( sL.GetKey(i).ToString() );
i++;
}
|
|
|
|
|
But before I add those string to SortedList, how to strip to those strings which are separated by the separator ("-") from the file?
Is testString.Split('-') any good?
Don't and drive.
|
|
|
|
|
Kant wrote:
Is testString.Split('-') any good?
Yes. That's the simplest way to do so as long as there are no carriage returns between strings and separators. In which case, I would suggest to concatenate strings as you read the file (use StringBuilder, for performance reasons, since strings are immutable), and then call Split on the full string.
|
|
|
|
|
how to write C# Applet, display it in a web page and the requirement?
Thank in advance for your help.
where ?documentation and tuto
-=zoltx=-
|
|
|
|
|
Basically, it's possible to run a .NET assembly into a IE6-hosted web page by adding these tags :
<object id="myCtl"
classid="http://www.mycode.Microsoft.com/mycode.dll#myClass">
</object>
where mycode.dll is the assembly filename, and myClass is the entry point.
Use http://127.0.0.1/... for local assemblies (you've got to put the assembly in your \wwwroot folder, if you are using IIS).
More info here[^].
|
|
|
|
|
thanks a lot. I want to know if it is possible to pass some parameters ex:
<object id="myCtl" classid="http://www.mycode.Microsoft.com/mycode.dll#myClass" param="2131" param2="qsdf">
|
|
|
|
|
thanks a lot. I want to know if it is possible to pass some parameters ex:
<object id="myCtl" classid="http://www.mycode.Microsoft.com/mycode.dll#myClass" param="2131" param2="qsdf">
-=zoltx=-
|
|
|
|
|
check this link which has sample,
http://www.codeguru.com/forum/showthread.php?s=&threadid=228806&highlight=C+applet
or search Codeguru , forums in C# section only with keyword "C# applets"
-Paresh
|
|
|
|
|
Does anyone has already created a com add-in for mappoint 2002 in C#?
If so, can you provide me some sample code?
I didn't found any usefull C# samples on the net (yet).
Thanks in advance.
|
|
|
|
|
Mappoint 2002 COM add-ins[^] are special COM components that must implement the IDTExtensibility2 interface.
In fact, once your C# code is ready (it must implements the mentioned interface), you just need to use regasm.exe to export it as an unmanaged component. Doing so, it creates a type-library and a progid you can use from MapPoint VisualBasic code.
My guess is that MapPoint 2003 will directly support C# objects.
|
|
|
|
|
|
Hi
I want to use the Keyeven but It dont fonction.
can anyone help me please.
also i used the button caption, but it dont fonction when i do a evenement .
thanks
void textBoxText_KeyUp(object sender, System.Windows.Forms.KeyEventArgs e)
{
if(e.KeyCode == Keys.ControlKey)
{
this.textBox.Text = "salut";
);
}
else this.textBox.Text = "salut";
if(e.KeyCode == Keys.Delete) this.textBox.Text = "salut";
this.textBox.Text = "con";
}
|
|
|
|
|
Conditions like e.KeyCode == Keys.ControlKey are valid, and they work. The code snippet you have posted is utter crap (does not even compile), but may be it wasn't on purpose.
|
|
|
|
|
Hi!
I have create my own control in C#. When I try to use it on my WIndows Form I get an HRESULT exception and the control is never created. Anyone knows how can I debbug this in order to detect the error???
Thanks in advance!
|
|
|
|
|
Hello,I'm trying to write a class library which can parse several WebPages automatically by mshml. But I'don't know
how to get a free IHTMLDocument2 interface which is not attatched to any control or view.
Using C++,this can be done by call to CoCreateInstance() function:
MSHTML::IHTMLDocument2Ptr pDoc;
HRESULT hr = CoCreateInstance(CLSID_HTMLDocument, NULL, CLSCTX_INPROC_SERVER,IID_IHTMLDocument2, (void**)&pDoc);
I want to know how to get a free IHTMLDocument2 interface in csharp.
hope I get some replies,
thanks
|
|
|
|
|
It's pretty much unnatural, but here it goes :
using mshtml;
using System.Runtime.InteropServices;
[ ComImport, Guid("7FD52380-4E07-101B-AE2D-08002B2EC713"),
InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] public interface IPersistStreamInit
{
IntPtr GetClassID();
void IsDirty();
void Load(IntPtr pStream);
void Save(IntPtr pStream, bool fClearDirty);
long GetSizeMax();
void InitNew();
}
{
mshtml.HTMLDocumentClass doc = new mshtml.HTMLDocumentClass();
IPersistStreamInit pS = (IPersistStreamInit) doc;
pS.InitNew();
doc.createElement("<a href='http://www.codeproject.com'>link</a>");
MessageBox.Show ("nb elements = " + doc.all.length);
...
}
|
|
|
|
|
|
hi,.S.Rod.
I'm extracting all links from a webpage,after I'use
doc.createElement("link");
how I get all links from page "codeproject".
|
|
|
|
|
Semantically a link tag is not an hyperlink tag. An hyperlink tag is known as an anchor. A link tag is what refers to external javascript or css files.
To know which method, collection or member to call, you must first define what you call a link. And then, either you have a collection ready for use (such as doc.anchors for all hyperlinks), or you'll have to parse the entire DOM tree matching tag names.
Good luck!
|
|
|
|
|
Hello,
In my project I have two forms:
frmMainForm (Mdi parent)
frmLogon (dialog)
- components on frmLogon: (edUserName, edPassword, edDatabase) - TextEdit
(btnOk, btnCancel) - Buttons
In frmMainForm Load event i wrote this code;
{
frmLogon Logon = new frmLogon();
Logon.ShowDidalog();
if (Logon.DialogResult == DialogResult.OK)
{
this is my problem, I don't know how can I get values from edUserName, edPassword... to build connectstring.
I mean something like that string username = Logon.edUserName.Text;
}
}
I hope you understand me
Thank you for answers
Anze
/*sorry about my bad English*/
|
|
|
|
|
The best thing to do is to implement your dialog results through properties of the frmLogon, i.e.
In your frmLogon, you begin by declaring some private fields
private string userName;<br />
private string password;<br />
private string databaseName;
Then, you create the properties (also in fmrLogon)
public string UserName<br />
{<br />
get<br />
{<br />
return userName;<br />
}<br />
set<br />
{<br />
userName=value<br />
}<br />
}<br />
<br />
public string Password<br />
{<br />
get<br />
{<br />
return password;<br />
}<br />
set<br />
{<br />
password=value<br />
}<br />
}<br />
<br />
public string DatabaseName<br />
{<br />
get<br />
{<br />
return databaseName;<br />
}<br />
set<br />
{<br />
databaseName=value<br />
}<br />
}
After this, don't forget to update your variables when the user presses the OK button. Something like
private void button1_Click(object sender, System.EventArgs e)<br />
{<br />
this.UserName=textBox1.Text;<br />
this.Password=textBox2.Text;<br />
this.DatabaseName=textBox3.Text;<br />
}
Having done this, you are now able to access your dialog results in the main form through the properties. For example...
frmLogon Logon=new frmLogon;<br />
<br />
if(Logon.ShowDialog()==DialogResult.Ok)<br />
{<br />
<br />
this.myTextBox=Logon.UserName +Logon.Password +Logon.DataBaseName<br />
}
|
|
|
|
|
Hello,
I don't know how add images to main menu or popup menu.
Thank you for answers
Anže
/*Sorry about my English*/
|
|
|
|
|