|
Interesting that System.Convert is in there. I think I've only ever used it about twice (well directly, anyway).
Regards,
Rob Philpott.
|
|
|
|
|
Rob Philpott wrote:
Interesting that System.Convert is in there |
Most people don't "like" the class. It's not interesting which is better, what is interesting is whether the *interviewer* would ask why I choose the class. Chances are, the question never comes.
static void Main(string[] args)
{
string s = null;
Console.WriteLine((string)s);
Console.WriteLine("" + s);
Console.WriteLine(Convert.ToString(s));
Console.ReadLine();
}
Now, an object that can contain null would not be casted to an Int - most people would parse it (and ignore any conversion errors). If prefer to convert it all if there's a lot of different types after another that need to be assigned. Otherwise, I go for casting.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
You use Object itself more than say String?
|
|
|
|
|
jschell wrote:
You use Object itself more than say String? Dunno, I did not measure them - just the first five non-structs that popped into my head. A string is still a pointer to an array of bytes to me. Nothing fancy, just an address. Outside of that, it's a shame Interfaces were not included, it would have made the answer much more interesting.
Given inheritance, I'd say I use a LOT of Object
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
|
I responded Object first then String, List, maybe Int even it's a struct and Debug, Console, something like that.
|
|
|
|
|
This is where you wished you'd remember something absurdly obscure like AsyncStateMachineAttribute.
|
|
|
|
|
B413 wrote: What is the best answer to this question?
If an interviewer thinks there is a best answer to that question then you can be sure that the interviewer doesn't know what they are doing. At best they don't understand the interview process and at worst they are arrogant.
There are of course bad answers to that question - like "what is a class?"
|
|
|
|
|
system.web.ui
system.io
system.data
system.configuration
system.data.sql

|
|
|
|
|
System.web.ui
system.io
system.data
system.data.sqlclient
system.configuration 
|
|
|
|
|
|
Suspicious link is suspicious. And "not an image". Try this one: http://i.imgur.com/NzoGrFa.png[^]
This looks trivial to OCR. That term should get you started.
|
|
|
|
|
The technique you are looking for is Optical Character Recognition. Good luck.
|
|
|
|
|
|
|
thanks in advanced but i have seen this but cannot use it give a lot of error.
do you have and ready example and dll's.
and
Can it convert the sample image of mine to number or not?
|
|
|
|
|
jojoba20 wrote: Can it convert the sample image of mine to number or not?
This is where YOU do the research to find out. Nobody else is going to do YOUR work for you.
The only way to find out is to try it and I don't think anyone is going to do your work for you for free.
|
|
|
|
|
I think Emgu (an openCV wrapper) can do this. Alternatively check out AForge.Net
|
|
|
|
|
Hey there,
can you help me or tell me about your expirience with IPropertySetStorage? I found this by Google and i think this is what i have to use to set custom file properties.
Is there anybody who use this before and can tell me a little bit more about it?
Thanks a lot!
|
|
|
|
|
|
Hi,
I have crrated below windows service and installed it using InstallShield. I am able to see the windows service Started in the Control Panel-Services but I am not getting any email when the minutes turns to 30.
Can anyone help please...
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Linq;
using System.ServiceProcess;
using System.Text;
using System.Net.Mail;
namespace MyTestWindowsService
{
public partial class MyTestWindowsService : ServiceBase
{
public MyTestWindowsService()
{
InitializeComponent();
if (!System.Diagnostics.EventLog.SourceExists("MyTestWindowsService"))
{
System.Diagnostics.EventLog.CreateEventSource("MySource", "MyNewLog");
}
eventLog1.Source = "MyEventLogSource";
eventLog1.Log = "MyNewLog Comes here!";
}
protected override void OnStart(string[] args)
{
eventLog1.WriteEntry("In OnStart");
}
protected override void OnStop()
{
eventLog1.WriteEntry("In onStop.");
}
protected override void OnContinue()
{
eventLog1.WriteEntry("In OnContinue.");
}
private void timer1_Tick(object sender, EventArgs e)
{
if (DateTime.Now.Minute == 30)
{
eventLog1.WriteEntry("starting to send email.");
try
{
MailMessage mail = new MailMessage();
SmtpClient SmtpServer = new SmtpClient("smtp.gmail.com");
mail.From = new MailAddress("it@mydomain.com");
mail.To.Add("jassim@mydomain.com");
mail.Subject = "Test Mail";
mail.Body = "This is for testing SMTP mail from GMAIL";
SmtpServer.Port = 587;
SmtpServer.Credentials = new System.Net.NetworkCredential("it@mydomain.com", "mypassword");
SmtpServer.EnableSsl = true;
SmtpServer.Send(mail);
eventLog1.WriteEntry("email sent.");
}
catch (Exception ex)
{
eventLog1.WriteEntry("failed sending email.");
}
}
}
}
}
Technology News @ www.JassimRahma.com
|
|
|
|
|
What do you see in the logs?
|
|
|
|
|
Application: MyTestWindowsService.exe
Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: System.ArgumentException
Stack:
at System.Diagnostics.EventLog.CreateEventSource(System.Diagnostics.EventSourceCreationData)
at MyTestWindowsService.MyTestWindowsService..ctor()
at MyTestWindowsService.Program.Main()
and
Faulting application name: MyTestWindowsService.exe, version: 1.0.0.0, time stamp: 0x53f98df6
Faulting module name: KERNELBASE.dll, version: 6.1.7601.17514, time stamp: 0x4ce7c78c
Exception code: 0xe0434352
Fault offset: 0x000000000000a49d
Faulting process id: 0x390
Faulting application start time: 0x01cfbf77f09ff94c
Faulting application path: C:\Program Files (x86)\My Company Name\My Product Name\MyTestWindowsService.exe
Faulting module path: C:\Windows\system32\KERNELBASE.dll
Report Id: 2e918d18-2b6b-11e4-8030-50b7c362601a
Technology News @ www.JassimRahma.com
|
|
|
|
|
Let's take a look at that.
Jassim Rahma wrote: The process was terminated due to an unhandled exception. So, there's some exception that caused the application to terminate. The stacktrace shows also on which line this exception occured:
System.Diagnostics.EventLog.CreateEventSource("MySource", "MyNewLog"); Since it is an ArgumentException, we check MSDN[^] for the arguments required and a list of when this exception might be thrown:
- source is an empty string ("") or null.
- logName is not a valid event log name. Event log names must consist of printable characters, and cannot include the characters '*', '?', or '\'.
- logName is not valid for user log creation. The event log names AppEvent, SysEvent, and SecEvent are reserved for system use.
- The log name matches an existing event source name.
- The source name results in a registry key path longer than 254 characters.
- The first 8 characters of logName match the first 8 characters of an existing event log name.
- The source cannot be registered because it already exists on the local computer.
- The source name matches an existing event log name.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|