Required functionality is to get the return week number of a given date.
8th march 2010 is the given date then it should return "2" as 2nd week.I have implemented a below method which return week number of the year, whereas requirement is return week no of the current month.
Could any body help me out from this scenario.
or if your looking for how many business weeks (ie weeks starting on sunday) you can use this
staticint weekNum2(DateTime T)
int weekNum = 1;
DateTime w = new DateTime(T.Year, T.Month, 2);
while (w <= T)
if (w.DayOfWeek == DayOfWeek.Sunday)
w = w.AddDays(1.0);
I have build a windows service that I wan't to deploy on another operating system.
The service is build in C# .NET 3.5 on a Windows XP Pro PC.
I wan't to deploy the service to another maschine that has the same operating system.
For that I have created an Installer class in my service project and also I have build a setup project that includes the service project.
When I move the executable code to the target maschine and run the setup everything seems to go well. But I cannot se the service?! I don't wan't to use the installutil feature.
Everything is programmed in Visual Studio 2008.
What can be wrong?
Do I have to use the installutil and how can I automitacally call that feature så that the service will be installed properly. I also wan't my service to be started automatically.
My customer is not used with this type of applications therefore I wan't everything to be done automatically.
My solution in Visual Studio consists of several projects.
1. One DLL project which holds the business code
2. One project that is the service - reference is made to previous project
3. One Console project used to force a execution without the service - reference is made to first project (DLL project)
4. Setup deployment project - reference is made to the service
In C# web application Requirement is when using admin panel admin inserts categoy,product etc then update also his store database on Ebay i hv integrated site with Ebay store db and updating that too. But Saving data takes time and Admin gets logout automatically I think default session time is up Plz help how to handle this
Not necessary that Session has timed out. It could be databse transaction timeout too. Or the established Connection timeout. You need to debug and find where the bottle neck is and increase the time accordingly.
Reading and writing values in the registry is the same regardless of the format. In the case of REG_BINARY the returned object is of type byte. The following code would convert that to a string. You would reverse the process to write it back.
RegistryKey regKey3 = Registry.CurrentUser;
RegistryKey regSub3 = regKey3.OpenSubKey("Software or whatever");
byte ans = (byte)regSub3.GetValue("Value I need");
string sString = System.Text.Encoding.ASCII.GetString(ans);
string  sArray = sString.Split('\0');
sString = "";
foreach (string s in sArray)
sString += s;
Now sString should have your string from the reg_binary ready for processing.
private int RandomNumber(int min, int max)
Random random = new Random();
return random.Next(min, max);
and i am clalling this method in for loop. my expectation is for every iteration in the loop i am expecting some new random number. code for that is like below:
Don't instantiate a new Random every time. Treat random as a singleton.
Random will (by design) give you the same sequence of numbers every time unless you start with a different seed. Right now you are getting the first number of the sequence every time.
The opinions expressed in this post are not necessarily those of the author, especially if you find them impolite, inaccurate or inflammatory.
The default constructor for the Random class uses the system clock to seed the random number generator. Your code is running fast enough that the system clock has not changed between calls to the constructor, resulting in the same random numbers being generated each iteration. See the MSDN documentation for the Random constructor[^] for more clarification and a good example.
Last Visit: 31-Dec-99 18:00 Last Update: 6-Jul-22 19:30