|
I can create a method on any class called GetEnumerator(), it doesn't have to have anything to do with IEnumerable. Eg
public class DumbClass {
public string GetEnumerator() { return "Good morning";}
}
Not very useful but now I can say
DumbClass x = new DumbClass();
Console.WriteLine(x.GetEnumerator());
ForEach needs an implementation of IEnumerable.
|
|
|
|
|
PaulLinton wrote: I can create a method on any class called GetEnumerator(), it doesn't have to have anything to do with IEnumerable
I meant the one that comes with the interface.
|
|
|
|
|
Nothing "comes with" an interface.
|
|
|
|
|
It's possible for a class to have a GetEnumerator method without actually implementing IEnumerable.
|
|
|
|
|
|
Hi,
I've made a Web Crawler in C#.Net and it crawls a given url in the textbox for all the url's on the page and stores in database.
Then taking one url at a time it again crawls all the urls for email addresses on the contact page of the website.
Now what i want is that when i open my web browser and open google.com search for anything and the results which come out, i mean it gives all the links n urls so i want my tool to work there.
I want my web crawler to work with the google.com results... right now i'm manually providing one url in the textbox for the whole crawling procedures.
I hope i can get good advice and suggestion to solve my problem.
Thanks
Paritosh Tripathi
B.Tech. (C.S.)
|
|
|
|
|
|
Can a windows service be started automatically by an installer? I plan to distribute the service via CD-Rom so the installation needs to be as simple as possible.
"Make it as simple as possible, but no simpler" Issac Newton
|
|
|
|
|
Don't know if it can directly, but you can set it to start on reboot and ask the user to reboot after the install.
|
|
|
|
|
I placed a msgbox in there for sh*t's and giggles, and it worked fine. Then I moved the SetText snippet to FormLoad, and it worked fine. However, it refuses to work in my event handler, and that's when I need to use it. Is this a bug?
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;
using iTunesLib;
namespace WIKDSPK
{
public partial class Form1 : Form
{
private iTunesAppClass m_iTunes = new iTunesAppClass();
public Form1()
{
InitializeComponent();
try
{
m_iTunes.Resume();
m_iTunes.OnPlayerPlayEvent += new _IiTunesEvents_OnPlayerPlayEventEventHandler(m_iTunes_OnPlayerPlayEvent);
}
catch (COMException)
{
Application.Exit();
}
}
private void m_iTunes_OnPlayerPlayEvent(object iTrack)
{
string iTArtist = ((IITTrack)iTrack).Artist;
string iTName = ((IITTrack)iTrack).Name;
string iTAlbum = ((IITTrack)iTrack).Album;
string m_iClipStr = "Now Playing [ Artist: " + iTArtist + " Name: " + iTName + " Album: " + iTAlbum + " ] www.xxxxxxxx.org";
Clipboard.SetText("Test");
}
}
}
PS> The event handlers are working 100%
|
|
|
|
|
I've got to ask this (it's going to sound stupid), but are you pasting it or using Clipboard.GetText()?
I sat up a couple of events and had the Clipboard.SetText(string) run and it copied to the clipboard just fine.
Have you tried stepping through your code?
|
|
|
|
|
As I said. If I move Clipboard.SetText to FormLoad, it works fine. However, if i nest it within my iTunes event handler, it's almost as if it doesn't even exist. Is this an Express Edition limitation? A bug?
The Clipboard.SetText("TEST"); is just for testing purposes... In addition, I know that the event is being handled because if I place MessageBox call in there, pointing to iClipStr, it totally works.
|
|
|
|
|
Put MessageBox.Show(Clipboard.GetText()); under the Clipboard.SetText("TEST");.
If it says "TEST" in the messagebox, then it worked.
|
|
|
|
|
Well, I did that, and I got the MessageBox but the text field was empty. So it's still not forwarding the data to the clipboard. It's driving me nuts! Clipboard works fine everywhere else except my handler. I don't get it. The handler is being called... The MessageBox does come up!
|
|
|
|
|
Hi, All.
I am having a problem where I am not getting a bitmap of a PDF back. This code works fine in a single threaded version I have been using for the past 8 months. If I open MSPaint I can paste the clipboard fine.
Is there something else I have to do because of it being multi threaded?
AcroPDPage pdfPage = (AcroPDPage)pdfDoc.AcquirePage(0);
CAcroPoint pdfRectTemp = (CAcroPoint)pdfPage.GetSize();
AcroRect pdfRect = new AcroRectClass();
pdfRect.Left = 0;
pdfRect.right = pdfRectTemp.x;
pdfRect.Top = 0;
pdfRect.bottom = pdfRectTemp.y;
pdfPage.CopyToClipboard(pdfRect, 0, 0, 100);
Fails at this point - returns "null"
--> IDataObject clipboardData = Clipboard.GetDataObject();
if (clipboardData.GetDataPresent(DataFormats.Bitmap))
{
blah,blah
Any ideas would be greatly appreciated.
Richard.
|
|
|
|
|
Worked it out. Requires the ApartmentState to be specifically set to STA.
PDFWorker worker = new PDFWorker();
Thread doPDFWork = new Thread(worker.doPDFWork);
doPDFWork.ApartmentState = System.Threading.ApartmentState.STA;
|
|
|
|
|
anybody have any idea how does this metal sensor HMC1052L works?
|
|
|
|
|
What does this have to do with C#?
|
|
|
|
|
If you can see sharp you can see what he has in his hand.
|
|
|
|
|
I'm going to guess that it "detects" metal.
|
|
|
|
|
a couple of months ago i remember seeing somewhere in a newsletter that some large company would be releasing or did release a corba implementation for c#. ... i want to say it was novel but i can't find any google links.
i would like to use wcf but my server is going to be c# and client in c++.
not sure how interoperability works in wcf yet. (i'm sure none exists as an MS solution)
at the end i'll probably just write the client/server manually but some code generation of corba and idl would be a nice tool.
- lm
|
|
|
|
|
do you know what the question is infact? the question is to make the following methods without using prepared methods in String Class and operators += and +:
public String delete (String st, int startIndex, int len);
public String copy (String st, int startIndex, int len);
public String insert (String st1, String st2, int len);
public String concat (String st1, String st2);
public int pos (String st1, String st2, int len);
public int countOf (String st1, String st2, int len);
public String intToStr(int value);
public int strToInt (String value);
public String reverse (String value);
how can i answer to these question with considering the condition?
please help me and as you guessed it's a school homework.
thank you
|
|
|
|
|
dont use the String class...use the string type...thats what i'd do, i would also call the professor a moron probably in class...which explains my excellent grades in college. and like everyone mentioned before, if you get stuck at some specific place ask here, we will not do you homework for you. most of us didnt have these kind of resources when we took those classes, or didnt use them for anything other than very spcific questions if we did.
Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.
|
|
|
|
|
SomeGuyThatIsMe wrote: dont use the String class...use the string type...
How do you thing the 'String class' and the 'string type' differ ? Whatever you think, you're mistaken.
Christian Graus
Please read this if you don't understand the answer I've given you. If you're still stuck, ask me for more information.
|
|
|
|
|
I assumed it was a trick question, and that they couldnt use the String class, but using string instead would work, since they work the same, his assignment would be easy. and since String is capitalized i assume its a class, and since string isnt and VS changes it color jus tlike other base types(int, double, char, etc..), i call it a type, even though it is a class just to tell them apart. bad behavior, but old habits are hard to break. i realize they arent different aside from that. but if it wasnt a trick question and he cant use a foreach, or indexes, or any member function he's pretty hosed..tho what about Convert? does it have a method to take strings to char[]'s i cant remember.
Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.
|
|
|
|