.net-2.0

VB.Net 2005, how can I subtract a date from the (current date minus 7 days) and produce a number of days?

淺唱寂寞╮ 提交于 2021-01-27 14:21:40
问题 I have a date in the future e.g. 13/10/2008 I need to subtract the current date (today is the 28/09/2010) minus 7 days, so thats 21/09/2010 minus 13/10/2008, which would equal erm, 720 something ? But the current date won't always be 28/09/2010, obviously. I need the code for this. EDIT: When i said future I mean past :) 回答1: Sub Main() Dim dt As DateTime = New DateTime(2008, 10, 13) ' be careful what you are subtracting from what ' the date you have is not in the future (year 2008) ' if the

Derived List to Base IEnumerable

最后都变了- 提交于 2020-12-27 05:22:27
问题 I have the following code that compiles in .NET Framework version 4.0 and above: public abstract class MyBase { } public class MyDerived : MyBase { } public abstract class MyBaseCollection<T> : IList<T> where T : MyBase { protected readonly IList<T> deriveds = new List<T>(); public void Test() { // This line works in .NET versions 4.0 and above, but not in versions below. IEnumerable<MyBase> bases = deriveds; } #region IList members with NotImplementedException // ... #endregion } public

Derived List to Base IEnumerable

为君一笑 提交于 2020-12-27 05:21:07
问题 I have the following code that compiles in .NET Framework version 4.0 and above: public abstract class MyBase { } public class MyDerived : MyBase { } public abstract class MyBaseCollection<T> : IList<T> where T : MyBase { protected readonly IList<T> deriveds = new List<T>(); public void Test() { // This line works in .NET versions 4.0 and above, but not in versions below. IEnumerable<MyBase> bases = deriveds; } #region IList members with NotImplementedException // ... #endregion } public

How do you get a month name from an integer value?

纵然是瞬间 提交于 2020-12-10 07:32:24
问题 How do you get a month name from an integer value? e.g. 7 is July 回答1: // using the current culture - returns "July" for me string x = DateTimeFormatInfo.CurrentInfo.GetMonthName(7); // using a specific culture - returns "juillet" string y = CultureInfo.GetCultureInfo("fr-FR").DateTimeFormat.GetMonthName(7); 回答2: Using a custom format string: string name = new DateTime(2010,7,1).ToString("MMMM"); 回答3: Use the DateTime object's ToString() method. "MMMM" is the long month. "MMM" is a short

XMLDocument to xml file

谁都会走 提交于 2020-06-17 15:54:27
问题 In my web services I am sending a XML document using this code, XmlDocument doc = new XmlDocument(); doc.LoadXml(myBigData.Serialize()); return result = doc.DocumentElement; Now In my c# console app I am calling this web method using, XmlElement returnedDataFromWebMethod = myWbSercvices.WebMethod(); Now how can I convert this XML element to a xml file e.g. in my C drive so i can see if xml document as document, instead of going through it using foreach(XMLNode) 回答1: You may try this: var doc

Using Bit.ly API in ASP.NET 2.0

吃可爱长大的小学妹 提交于 2020-04-10 10:00:11
问题 Hey I was wondering if anyone can point me to some example on how to use Bit.ly API in ASP.NET 2.0 回答1: I've done a really quick convert from an answer I found in VB. I haven't tested this (sorry) but it may be of some help in the meantime, and I will sort it out to be a bit more C# style friendly. public static string BitlyIt(string user, string apiKey, string strLongUrl) { StringBuilder uri = new StringBuilder("http://api.bit.ly/shorten?"); uri.Append("version=2.0.1"); uri.Append("&format

Any VBNET equivalence of C# where generic constraint keyword?

人走茶凉 提交于 2020-02-27 15:09:05
问题 First, I wish to write myself a generic type for operations against the underlying Active Directory. For those of you who know about AD and the System.DirectoryServices namespace, the DirectoryEntry class is the top most important along with the DirectorySearcher class. When speaking the AD language, everything is a DirectoryEntry. With that said, my application needs to manage Users, Groups and Organizational Units (OU). Each of these objects are AD entries. Then, this sounds to me a good

Any VBNET equivalence of C# where generic constraint keyword?

自作多情 提交于 2020-02-27 15:08:21
问题 First, I wish to write myself a generic type for operations against the underlying Active Directory. For those of you who know about AD and the System.DirectoryServices namespace, the DirectoryEntry class is the top most important along with the DirectorySearcher class. When speaking the AD language, everything is a DirectoryEntry. With that said, my application needs to manage Users, Groups and Organizational Units (OU). Each of these objects are AD entries. Then, this sounds to me a good

Set Format of auto-generated columns in DataGridView having object DataSource

对着背影说爱祢 提交于 2020-02-15 10:29:29
问题 I would like to auto create all the columns for my DataGridView based on my custom class. Every thing works like it should, but what I need is to format and align the cell values. So is there an attribute that I can add to my field (HeightMeter) so that it can align and format as required. To do this in a manual column create code, You will use the following: DataGridViewColumn.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight; DataGridViewColumn.DefaultCellStyle.Format =

Set Format of auto-generated columns in DataGridView having object DataSource

情到浓时终转凉″ 提交于 2020-02-15 10:28:50
问题 I would like to auto create all the columns for my DataGridView based on my custom class. Every thing works like it should, but what I need is to format and align the cell values. So is there an attribute that I can add to my field (HeightMeter) so that it can align and format as required. To do this in a manual column create code, You will use the following: DataGridViewColumn.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight; DataGridViewColumn.DefaultCellStyle.Format =