|
float num = 18.3f;
This above stmt will run,But I read in a book that "if 18.3
taken as a double, so you would get a compiler error saying that a double cannot be implicitly converted to a float. Adding the f to the end of 18.3 does an explicit conversion."....But how is that possible?If we can cast Double value to int then why not convert Double to float? (Float is almost double ,right?)
|
|
|
|
|
If any value cannot be expressed fully with no loss when converted (i.e. 3.3 as an int is 3 so we lose .3), then it should use Explicit conversion. If however, if it will be identical when converted it should use explicit implicit 3 as a double still == 3).
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)
|
|
|
|
|
In this case you're not casting; casting would be float num = (float) 18.3; which would also work, but it still has to be done explicitly just as it would be for double-to-int.
|
|
|
|
|
18.3f is not a cast or a conversion it just tells the compiler to treat the literal as a float instead of a double.
Need software developed? Offering C# development all over the United States, ERL GLOBAL, Inc is the only call you will have to make.
Happiness in intelligent people is the rarest thing I know. -- Ernest Hemingway
Most of this sig is for Google, not ego.
|
|
|
|
|
madeline_veda wrote: Float is almost double ,right?
Good for memorable quotes [^].
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Thanks Buddies!I have very well understood the logic.Hope in future U all will help me like this.
|
|
|
|
|
I working with Active Directory Reset password.
DirectoryEntry DirEntry = GetDirectoryEntry();
DirEntry.UsePropertyCache = false;
DirEntry.Invoke("SetPassword", new object[] { newpassword });
DirEntry.CommitChanges();
The code is working fine but after changing the password I am able to login with both old password and new password. I found with my observation that after one hour approximately the old password expires.
Is there any way to expire the old password immediately when I change the password?
modified on Thursday, November 13, 2008 6:39 AM
|
|
|
|
|
Hint: How many domain controllers are on your network and how often to they sync up?
|
|
|
|
|
Currently I am using a test domain setup on a test machine. So there is only one Domain Control.
|
|
|
|
|
Assume you perform login authentication with code below :
bool loginResult = false;
using (DirectoryEntry de = new DirectoryEntry(this.SearchRoot.Path, userDN, password, AuthenticationTypes.Secure))
{
try
{
object x = de.NativeObject;
loginResult = true;
}
catch (COMException comEx)
{
}
return loginResult
}
Just Change the AuthenticationTypes to AuthenticationTypes.Secure will solve the problem. If the AuthenticationTypes is AuthenticationTypes.None then it will able to login with old password.
refer this :Windows Server 2003 Service Pack 1 modifies NTLM network authentication behavior
|
|
|
|
|
|
You're welcome
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)
|
|
|
|
|
Hi there
I have a file with allot of sentences. I need to make a dictionary with the words from that file. Until now I've separated the words and sort them using Split() and Sort() methods. My problem is to make a list without duplicate words. How can I do that?
static int n = 0;
public static string[] NoDuplicate(string[] array)
{
int i;
string[] res = (string[])array.Clone();
for (i = 0; i < array.Length-1; i++)
if (array[i + 1] != array[i])
res[n++] = (string)array[i];
return res;
}
1) how can I do it more neat?
2) i don't like that method because is initialized using Clone() and the lenght is too big.
many thx
|
|
|
|
|
Store words in dictionary. Before adding new word check if the dictionary already contains it or not.
|
|
|
|
|
First, I'd use a List instead of an array because a List can grow dynamically, and will only be as large as is required to store your data. To avoid duplicates, you could do this:
List<string> dictionary = new List<string>()
string sentence = GetNextSentence();
string[] words = sentence.ToLower().Split(' ');
for (int i = 0; i < words.Length; i++)
{
if (!dictionary.Contains(words[i])
{
dictionary.Add(words[i]);
}
}
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
Instead of using a List and calling it a dictionary, use a real Dictionary .
The Dictionary.Contains method is a lot faster than the List.Contains method.
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
why would you need key & value just to store a word though? I would've gone with John's suggestion myself.
|
|
|
|
|
The difference is the style of the storage object.
A list is just that, an unsorted sequential list of items. To do a Contains() operation on it, you have to iterate through the list and check every item.
On the other hand, a dictionary is a form of hash table, so a Contains() operation only has to hash the key and check if it already exists.
in .net 3.5 you could instead consider a HashSet<String> This is specifically optimised for sets containing no duplicates.
Simon
|
|
|
|
|
|
Ignore what I posted before, Simon's HashSet<string> is perfect, and it has the ToArray if you need it.
Leaned something new today
|
|
|
|
|
HashSet is only in .Net framework 3.5 and i;m using vs2005
But the advice is soo great, thx to all
|
|
|
|
|
Take a look at the HashSet<String>[^] class (.net 3.5 only). It provides an optimised hash collection and it doesn't allow duplicates, (it just ignores attempts to add duplicates), and you can call ToArray() when you are done with it if you really need a string array.
Simon
|
|
|
|
|
Nice find Simon, hadn't come accross this one before... always good to learn something new
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)
|
|
|
|
|
How could we know if SQL Server express is installed with c#? Thanks
|
|
|
|
|