|
no i understand my question but my problem is that i cant explain it ti your ,i want i find lenght of years
if there is overlap years i should delete one of them such as here
Start End
1995 2005
2000 2003
1998 2004 so for my question 2000 subtract 1995 and 2000-2003 is inside 1995-2005 so dont select it and also 1998-2004 inside in 1995-2005 i dont choose this years also so my totals years should be 2005-1995=10 my real question is that but how to do it i dont know
|
|
|
|
|
Don't start off by trying to think in code. Break the problem down using pen and paper. As a hint, you need to extract out the minimum start date and the maximum end date as a first step - only then can you start to remove the overlapping periods.
|
|
|
|
|
|
look at the value generated by the Subtract: it's not a DateTime, so you aren't using it.
Think about it: what do you get if you subtract one date from another? It can't be a date, because it doesn't have a reference point in time any more. It's a duration, or (in .NET speak) a TimeSpan.
Look at the TimeSpan structure[^], and you should find what you need in it's properties. Unless you want years or months, of course - because those require a reference point as well since they aren't all the same length.
If that's what you need, then try looking at this: Working with Age: it's not the same as a TimeSpan![^]
The only instant messaging I do involves my middle finger.
English doesn't borrow from other languages.
English follows other languages down dark alleys, knocks them over and goes through their pockets for loose grammar.
|
|
|
|
|
hi,
i have a dll and i wanted to copy this dll to application folder and add refrence of DLL. Then
Create Object for the CLass DLL
call the function sendsms with parameter
(username, password, senderid, mobnum, message, smsroute).
I have values for this parameters to pass. How to do that?
|
|
|
|
|
Depends on whether this is an activex dll or a .Net dll.
If its Activex, you need to import it - Importing and Extending ActiveX Controls in .NET[^].
.Net dll - just add reference, select this dll, instantiate this class and you will have access to public methods.
|
|
|
|
|
If the DLL contains a class, you need an extra step to call its member functions: You can create a wrapper class that creates one instance of the DLL's class on initialization, and frees it when done.
Calls to the wrapper-class methods just forward that call to the method of the same name in the single DLL-class instance.
To access the DLL, use (for example) this type of declaration:
[DllImport("ComGUIProxy.dll", EntryPoint = "InitializeContainer")]
public static extern bool InitializeContainer(int hContainer, int TicketID);
And put the DLL in the same folder as your executable.
|
|
|
|
|
plz help me how to create installer for windows application
|
|
|
|
|
|
|
|
string laceStrings(const string& s1, const string& s2)
{
if (s1.empty())
return s2;
if (s2.empty())
return s1;
string laced;
laced.resize(s1.size() + s2.size());
int i = 0, pos = 0;
int size = std::min(s1.size(), s2.size());
for ( ; i < size; ++i)
{
laced[pos++] = s1[i];
laced[pos++] = s2[i];
}
if (s1.size() >= s2.size())
for ( ; i < s1.size(); ++i)
laced[pos++] = s1[i];
else
for ( ; i < s2.size(); ++i)
laced[pos++] = s2[i];
return laced;
}
|
|
|
|
|
Sorry, but that's not how it works. We're not here to do your work for you. We'll help if you've got a specific question or problem.
|
|
|
|
|
{
("Let me see your code sir");
}
|
|
|
|
|
Adding to Dave's comment, you are asking a question about C++ and Python in a C# forum. That's not very clever.
|
|
|
|
|
|
Next time use Google & find write forum before posting questions.
Found this one[^] from Github. And alternatively you could Code Rewrite[^]
|
|
|
|
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication2
{
class Program
{
static void Main(string[] args)
{
List<DateTime> dtArray1 = new List<DateTime>();
List<DateTime> dtArray2 = new List<DateTime>();
Console.WriteLine("START Enter date");
for (int i = 0; i <= 2; i++)
{
string sStartdate1 = string.Empty;
sStartdate1 = Console.ReadLine();
DateTime dStartDate1;
if (DateTime.TryParse(sStartdate1, out dStartDate1))
{
dtArray1.Add(dStartDate1);
}
}
foreach (var item in dtArray1)
{
Console.WriteLine(item);
}
Console.ReadLine();
Console.WriteLine("end Enter date");
for (int j = 0; j <= 2; j++)
{
string sStartdate2 = string.Empty;
sStartdate2 = Console.ReadLine();
DateTime dStartDate2;
if (DateTime.TryParse(sStartdate2, out dStartDate2))
{
dtArray2.Add(dStartDate2);
}
}
foreach (var item in dtArray2)
{
Console.WriteLine(item);
}
Console.ReadLine();
}
}
}
|
|
|
|
|
|
int[] id1 = { 44, 26, 92, 30, 71, 38 };
int[] id2 = { 39, 59, 83, 47, 26, 4, 30 };
IEnumerable<int> both = id1.Intersect(id2);
foreach (int id in both)
Console.WriteLine(id);
/*
This code produces the following output:
26
30
*/
but how to compare with their index ,i mean i should compare id1[index0] with id2[index0] and each index if there will be intersection show result and of course result will be 0 because there not intersection with their index
|
|
|
|
|
Intersection does not work on index.
It works on values.
|
|
|
|
|
int[] id1 = { 44, 26, 92, 30, 71, 38 };
int[] id2 = { 44, 59, 83, 47, 26, 4, 30 };
hmmmm ok,if that,what i should do to get output 44
i want to compare 2 array element ,and if in the same place(which are in same index ) array are equal to show as result
|
|
|
|
|
You can customize your search (intersection) criteria without too much difficulty.
Override IEqualityComparer<T> .
Go through the example given here[^] on msdn.
|
|
|
|
|
This is not very "elegant" code, but I think you may be looking for a solution as simple as this:
int[] id1 = { 44, 26, 92, 30, 71, 38 };
int[] id2 = { 44, 59, 83, 47, 26, 4, 30 };
List<int> matches;
private void button1_Click(object sender, EventArgs e)
{
int[] shortAry;
int[] longAry;
matches = new List<int>();
if (id1.Length < id2.Length)
{
shortAry = id1;
longAry = id2;
}
else
{
shortAry = id2;
longAry = id1;
}
for (int i = 0; i < shortAry.Length; i++)
{
if (shortAry[i] == longAry[i]) matches.Add(shortAry[i]);
}
} When you exit this Button ClickEventHandler, then, if matches.Count == 0, there are no matches.
"What Turing gave us for the first time (and without Turing you just couldn't do any of this) is he gave us a way of thinking about and taking seriously and thinking in a disciplined way about phenomena that have, as I like to say, trillions of moving parts.
Until the late 20th century, nobody knew how to take seriously a machine with a trillion moving parts. It's just mind-boggling." Daniel C. Dennett
|
|
|
|
|
Try the Zip method[^]:
int[] id1 = { ... };
int[] id2 = { ... };
IEnumerable<int> both = id1.Zip(id2, Tuple.Create).Where(t => t.Item1 == t.Item2).Select(t => t.Item1);
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|