|
Mostly. The only member of Convert I use is ChangeType and that only in extreme circumstances.
|
|
|
|
|
What do you have against it?
It is a truth universally acknowledged that a zombie in possession of brains must be in want of more brains.
-- Pride and Prejudice and Zombies
|
|
|
|
|
|
I'll have to check my code at some point. I could've sworn I found places where I had to use the convert class instead of casting before.
It is a truth universally acknowledged that a zombie in possession of brains must be in want of more brains.
-- Pride and Prejudice and Zombies
|
|
|
|
|
Please do.
I've found ChangeType to be useful when I don't know the destination type at compile time and even generics won't help; it's rare. One example I have is loading a DataTable from a CSV file. Otherwise, if you know the destination type, just use it.
I ran a little test and found int.Parse to be 3% quicker than Convert.ToInt32 (ToInt32 requires an additional method invocation), which isn't much, but as it supports my position I'll consider it significant.
|
|
|
|
|
It was string to int conversion I was thinking of, although why int foo = (int)"1" fails but int foo = (int)'1'; does not is a question I'm afraid to ask.
It is a truth universally acknowledged that a zombie in possession of brains must be in want of more brains.
-- Pride and Prejudice and Zombies
|
|
|
|
|
It gives the ASCII value (Unicode code point / whatever) of the character, which I assumed is what he wanted.
|
|
|
|
|
sofi79 wrote: and it should create alternate numbers(written twice). for some single letters ( the most common ones a,e,o,r,t)
This part is not particularly clear.
Does it mean that if your scheme decides that the letter 'a' = the number 4, then it should be written as 44 "(written twice)", or does it mean something else?
Do you understand what it means? Because if not you should go back to the assignment setter for clarification. Make sure that you fully understand the problem before posting here.
You should also make some attempt at writing some code, so that you can demonstrate to people here that you are trying and not just asking someone else to write your assignment for you.
To get you started:
Research how to get a character from a string .
Research how to convert a char to an int
Good luck!
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
How can I Insert into Text File from Sql Table.
Is there a query like bulk insert for this work
In fact I need Invert of bulk insert ?
thanks in advanced
Hello Friends
|
|
|
|
|
You want to export an sql table? If so load it all to a table and write to a csv file, you can find examples of this anywhere on the web.
|
|
|
|
|
I have a C# program which does COM interop to a VB6 DLL via late-binding. The VB6 DLL then uses a 3rd party OCX to generate an image, the file path of which is passed back to my C# program so that it can display the image. This was all working just fine until I moved the C# program from .NET 1.1 up to .NET 2.0. Now, instead of using the program directory's version of the OCX, the COM DLL is using a version in the system32 directory which is causing problems. I can't for the life of me figure out why this is happening. I've played around with App.config files and done a few other things, but nothing is working. I don't know how to tell my C# program to use a COM OCX from a specific file location, especially when the file is not even directly referenced in the program. Again, if I compile it against .NET 1.1 it works fine, but with .NET 2.0 it breaks. Any ideas? This is really driving me crazy. Thanks in advance.
Here's an example of the late-binding code to the COM DLL:
Type myObjectType = Type.GetTypeFromProgID("MyComDLL.ClassToUse", true);
object myObject = Activator.CreateInstance(myObjectType);
myObjectType.InvokeMember("Load", BindingFlags.InvokeMethod, null, myObject, null);
|
|
|
|
|
Greetings,
Now I have my C# socket server running which accepts PowerShell input from a perl socket client running on Linux and sends reply back. I have read through and tried all the sample code on all the websites. But there seems to be a prolem with all of them (and mine). Whenever I invoke "get-acl" command from the client perl program I get this reply from the server: System.Security.AccessControl.DirectorySecurity instead of: the normal output that I see on the Powershell prompt.
But when I run the get-command at the same prompt I get the desired output.
Am I missing something here? Does this mean that getting the functionality of Powershell through this is not possbile? Has anyone tried this ?
Any help will be greatly appreciated.
Best Regards,
sk
|
|
|
|
|
A website is usually running under a restricted user-account. When you run it from the desktop, you're running under the account that you logged into.
I'm not using webservers much, at this point I'd seek out the admin and ask him. Anyway, there are more readers/posters on this thread, maybe someone can explain it better, so that I can learn from it too
I are troll
|
|
|
|
|
Thanks for the reply, hopefully someone has worked on this before. Anyone?
|
|
|
|
|
Again, the ASPNET account that your website is running under has very limited permissions to the system, for obvious security reasons.
You have to change the account that your web site is running under to another account that has the permissions you need to do what you want. This is normally done in IIS Manager.
|
|
|
|
|
Thanks for the tips Dave, but I am running a C# Socket server, asp.net and IIS are not involved in this application. My c# socket server listens on a port listens for a TcpClient, creates a NetworkStream, GetBytes from the client, covert those bytes to string, passes that string to RunShell method which executes that string as a power shell command, coverts that string to bytes, sends it off to the client.
The problem is that all the "string" commands executed by the powershell method are not executed the way they are on a regular powershell prompt. for example get-command works fine but get-alias does:
get-alias on regular powershell prompt:
CommandType Name Definition
----------- ---- ----------
Alias ac Add-Content
Alias asnp Add-PSSnapin
Alias clc Clear-Content
get-alias from my c# prompt:
Sending parameters: 'get-alias'...<done
Welcome to power shell server ...
ac
asnp
clc
cli
-----------
Any ideas?
Best Regards,
sk
|
|
|
|
|
In that case, I have no idea since I've never used PowerShell. Sorry...
|
|
|
|
|
|
Hi All,
Crazy question but it just popped into my head I Google hasn't returned anything so far. How many interfaces can a class implement?
Obviously from a coding standards POV it's going to only ever be a handful at most but is there an absolute maximum number that can be implemented before the compiler complains?
Cheers,
|
|
|
|
|
There are no hard and fast interface limits. Obviously, the more interfaces your class implements, the more likely that you're entangling concerns that could be better implemented elsewhere.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
For sure. I was just writing a tech spec at work and was talking about the pros/cons of interfaces vs abstract classes and the question just popped into my head.
I don't think I've personally ever strayed past 2-3 yet (including IDisposable type interfaces).
|
|
|
|
|
There is no documented limit. Though, it would probably be capped by available memory at compile time. Depending on the number of things the class has to implement and the amount of code hanging off of it, this could be a few (MASSIVE) interfaces, or it could end up being millions of small ones.
|
|
|
|
|
Indeed. I've got a couple of MASSIVE interfaces (10+ 'things') but they're in a composite application using DI.
Eeek, even the thought of "millions of interfaces" fills me with dread. ;D
|
|
|
|
|
hello people all around the globe!
I would like some help from your side, I want to display a 3d graph similar like the one in excel in a C# desktop application. The data I will get from sql query and then display in a 3d graph.
Any advice? Thanks, Laziale
|
|
|
|
|