|
Thanks. Didn't know the difference.
|
|
|
|
|
please how can i get from that string "80-247-0092-1 Grada Publishing" to one string first code (ISBN) and to second string everythig gehind this isbn code? ... please help me ... again
-----------------------------
Computer is my hell on earth
|
|
|
|
|
If the ISBN is always followed by a space character, you can use: String.Split(new Char[] {' '}, 2)
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook www.troschuetz.de
|
|
|
|
|
Hi
I was hoping for someone to come out with an idea for a situation i came across..pls bear with me, its a bit long, and i shall explain with code.
this is a sample of my class:
public class Customer<br />
{<br />
private Dictionary<long, Membership> membershipDict;
private Dictionary<long, Address> addressDict;
<br />
public Membership GetMembershipByKey(long key)<br />
{<br />
if (membershipDict.Contains(key))<br />
return membershipDict[key];<br />
}<br />
<br />
public void InsertMembership(Membership membership)<br />
{<br />
if (!membershipDict.Contains(key))<br />
membershipDict.Add(membership.MemberhsipId, membership)<br />
}<br />
<br />
}<br />
My problem is, I would have lots of methods to just retrieve and insert my Dictionaries of memberships and addresses. And there are more of these dictionaries in my Customer Class. I was thinking of replacing these with Generic Method, for example:
public T GetObjectByKey<T>(long key)<br />
{<br />
}
But internally I would need some mechanism to tell me which T is being called. I was thinking of using a Dictionary to keep this info, but its strongly typed, and I cannot use a dictionary to keep a keypair value of Type, and Dictionary<T,K>.
I was thinking of letting my Membership and Address classes inherit from an interface, let's say IModel.
So i would have dictionaries:
private Dictionary<long, IModel> membershipDict;
private Dictionary<long, IModel> addressDict;
so that i can keep a:
Dictionary<System.Type, Dictionary<long, IModel>> typeDict;
but I dont really like this approach. Sorry for the very long explanation, but i hope it explains my dilema. I am looking forward to some great suggestions. Im fairly new with C# and generics. Im just looking for a way to shorten my code. Would hate to have same methods repeating everywhere...
Cheers
|
|
|
|
|
First of all have you thought of subclassing the Dictionary<string,YourObject> ?
For what you are asking two are the simplest ways i see based on what i have understood.
You can use a general function with parameter object or a common base object like BaseMemeberShip for all possible MemberShip objects to be added. Then by using the is Address for example determine to which dictionary you will add it. You can also use GetType()
A second way which probably is the same from the functional scope, is to implement an interface which somehow signals what kind of Membership Object it is you are adding.
|
|
|
|
|
Hi
thanks for the reply. But I dont get what you are saying, either i mis-interpret or u misunderstood my meaning.
I guess what im getting at is for this function
public T GetObjectByKey<T>(long key)<br />
{<br />
Type t = typeof(T);<br />
}
I hope that makes sense....
|
|
|
|
|
HOW CAN I OPEN OPENDIALOG IN CLIENT-SIDE AND LIST FILES AND DIRECTORIES IN CLIENT-SIDE?
ALA QUNAIBI
|
|
|
|
|
DON'T SHOUT !!!
In ASP.NET 2.0, there's a control for this. In 1.1, I believe you had to use the old HTML file input tag.
This belongs in the ASp.NET forum, really.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Hi,
Using .Net 2.0
I have created webservices inside a project. These services are in a solution on my machine which I am developing.
To reference these services, I use Add Web Reference, webservices in this solution (Because the services are saved in my local machine).
At what stage should I place these webservices in the virtual directory of a webserver?
Should these webservices be developed in a virtual directory on my local machine as opposed to in the local C drive as it is now?
The intension is that others be able to see these webservices as they are being developed.
For an example, from my machine to reference one of the webservices, this is the path I use:
http://localhost:2144/inTest.asmx
does this mean that other developers to reference this webservice should use:
http://MyMachineName:2144/inTest.asmx
??
Thanks
|
|
|
|
|
fmardani wrote: Should these webservices be developed in a virtual directory on my local machine as opposed to in the local C drive as it is now?
A webservice will always be on your hard drive, it will simply be in a directory that is mapped to a folder in IIS. VS.NET is mapping it for you, it has a web server built in. You should probably leave it where it is, so you can debug it and work on it. Deploy it when you move it to a machine it will run on.
fmardani wrote: does this mean that other developers to reference this webservice should use:
They should probably reference it locally on their machines. If you want it somewhere that people can run it, but not work on it, then you may want to set up a machine to host it.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Is there any code for automatic generation of a password.
thnaks
|
|
|
|
|
I haven't seen one but it can't be that hard to create a function that takes a random number and returns a char based on the ascii values you allow.
I think System.Convert.ToChar(int) is probably the function you need from the top of my head.
Russell
|
|
|
|
|
arachnoid wrote: I think System.Convert.ToChar(int) is probably the function you need from the top of my head.
Use it with Math.Random, but you'll end up having a senseless password!!
All generalizations are wrong, including this one!
(\ /)
(O.o)
(><)
|
|
|
|
|
i was thinking that that was the critical function rather than using that as the whole algorithm.
Then create a wrapper that creates a random number between 0 and 61 and returns an lcase, a ucase or a number with equal probability
Russ
|
|
|
|
|
It is like an automatic generation for an activation code.
Maybe my description as a password was some how wronge
|
|
|
|
|
use math.random to create a nuber between 0 and 61
use a switch statement for 0 to 25, 26 to 51, 52 to 61
convert the numbers to letters or numbers using system.convert.tochar(int) and these values ^
loop to create a pwd of required length
HTH
Russ
|
|
|
|
|
Create a char array with all the 'allowed characters'
Call up a random number between 0 and the length of that array for the amount of characters the password should contain.
V.
I found a living worth working for, but haven't found work worth living for.
|
|
|
|
|
|
I think the biggest problem a lot of password generating programs have is that they don't guarantee a strong password. While choosing random characters from a set of predifined values might get you very diversive password, it doesn't mean it always will. So despite using long password, you could still end up with weak ones like 'ifdhgkfsd'. There should be some code to check, if teh generated password meets some special requirements, and possibly do some adjustments. A good example for this is the built-in membership provider for ASP.NET 2.0, which requires you to have at least one non-alphanumerical character in your password. Then again it's not a generator tool, it just checks a given password. I don't mean to stay you need these precautions in every case, however I do mean you should find (or possible write) code that allows usage of similiar features. For example:
public string GetPassword(int length, int minUppercaseLetterCount, int minNumberCount, int minNonAlphanumericalCount)
{
//your code here
}
Obviously, for simple passwords you would use it like GetPassword(5, 0, 0, 0). And if you ever need strong passwords you can still reuse this function.
I think this smells like an article . Someone should write it. Or maybe I will .
|
|
|
|
|
it smells like an article but you should add to it some code
szukuro wrote: I think the biggest problem a lot of password generating programs have is that they don't guarantee a strong password.
i thought about this problem. SO i took the function that GUFFA provided and i am trying to implement it in a way to force it to generate some strong password with at least 2 digits in it.
|
|
|
|
|
Obviously by writing an article I also meant writing the code, since the article itself would be pretty much the code itself, with some explanation .
|
|
|
|
|
when i run my program (login as standard user on vista) it gives access denied on a process( created from System.Diagnostics.Process).But when i logged in as administrator) it get access.
How can i grant permission on process.Please suggest me...
|
|
|
|
|
Hello everyone,
Anyone knows how to insert a chart in a windows form??
Many thanks
All generalizations are wrong, including this one!
(\ /)
(O.o)
(><)
|
|
|
|
|
You have two options
1 - buy/download a charting control
2 - write the code to draw a chart
Once you have your chart, on a bitmap, you can either draw it in your paint event, or use a picture box
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Thank you Graus, please tell me where I can find a free download.
Many thanks
All generalizations are wrong, including this one!
(\ /)
(O.o)
(><)
|
|
|
|