|
Sort of like poking a stick into a hole and seeing if something will grab onto it. I like picturing grizzly bears.
It was only in wine that he laid down no limit for himself, but he did not allow himself to be confused by it.
― Confucian Analects: Rules of Confucius about his food
|
|
|
|
|
As others have pointed out, no one here is going to write your program for you. Let's step back from that statement for a second and consider why we won't do that.
The first point is that, for the most part, we are all professional programmers on this site and what you are asking is for someone to build something for you, for nothing. Imagine going onto a site for construction workers and posting a blueprint of the house you want building. How many responses do you think you would get saying they would build it for you?
Next, you have to remember that we know what you're asking for here. You're asking for us to write your homework for you and that's asking for us to help you to cheat. You might not see that as a big thing but we do. If you don't understand how to do this task and someone helps you cheat then you haven't learned how to do this task. At some point in the future, you may end up working alongside one of us and we could have to make up for the fact that you have come into the profession not knowing how to do a simple task like this. You already have all of the requirements here so it should be a simple enough task for you to work out how to do this.
If the reason you want to cheat is because you don't know how to do this task then that's probably down to one of these three reasons.- You haven't been taught how to accomplish the parts of this task. If that's the case, you need to talk to the person who set out the task to get guidance
- You have been taught it, you just weren't paying attention. Well, that's on you. Don't expect us to dig you out of that hole
- You have been taught how to do this, but you don't have the aptitude to be a developer. There's no shame in this, there are always things we aren't capable of doing. I'm not capable of flying a fighter jet at Mach 2, I'm not going to feel ashamed over that. If you aren't meant to be a developer, find something else you can do. Don't continue struggling over things that you aren't meant to be.
|
|
|
|
|
Can someone show me how to send GMmail using C#???
I just spent an hour Googling and the closest thing that I found was this page which only lists the folders in my gmail account. This seems like it's WAYYYY over conmplicated.
I tried this based on some snipptes I got off Google, but I get auth errors
class Program
{
static void Main(string[] args)
{
var client = new SmtpClient("smtp.gmail.com", 465)
{
UseDefaultCredentials = false,
Credentials = new NetworkCredential("me@gmail.com", "mypass"),
EnableSsl = true,
};
client.Send("me@gmail.com", "me@gmail.com", "Test", "This is a test");
Console.WriteLine("Sent");
Console.ReadLine();
}
}
I get either "Failure sending email" with port 465, or "'The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.7.0 Authentication Required" usig port 587.
I thought it would be as simple as this, bu there doesn't seem to be a clear example that works.
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.
|
|
|
|
|
|
Depending on your account settings, you may need to create an app password to allow your application to bypass 2SV:
Sign in with App Passwords - Google Account Help[^]
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
okay, we know that's not possible via the usual save/restore techniques for damn good reasons:
1) Func and Action (delegates) can have references to external objects/states the compiler can't resolve.
2) if that could be done, it would be an ideal way to insert/execute malicious code.
as i see it, now, that leaves two alternatives:
1) have some kind of plug-in architecture that exposes pre-defined delegates. but, that could also be vulnerable to security threats. more critical would be the delegates defined in the plug-in need for access/reference to the definitions/references of internal objects in the app it would manipulate.
2) a DSL/script-language that could be saved/restored as text, and then compiled via Roslyn reflection/emit, etc.
a concrete example of the type of Func i'd iike to save:
private static readonly Random rand = new Random();
private double IntensityFunc(Edge edge)
{
var hour = DateTime.Now.Hour;
if (hour > 3 && hour < 12) return edge.IntensityMin;
if (hour > 22) return edge.IntensityMax;
return rand.NextDouble() * (edge.IntensityMax - edge.IntensityMin) + edge.IntensityMin;
} mini-example showing Node and Edge definitions, and Func usage:
public class Node: INode
{
public Node(string name, int id)
{
Name = name;
Id = id;
}
public string Name { set; get; }
public string Id { set; get; }
}
public class Edge: IEdge
{
public Edge(Node node1, Node node2, double intensity, double intensityMin = 0.0, double intensityMax = 0.0,
Func<Edge, double> intensityFunc = null)
{
Node1 = node1;
Node2 = node2;
Intensity = intensity;
IntensityMin = intensityMin;
IntensityMax = intensityMax;
IntensityFunc = intensityFunc;
}
public Node Node1 { set; get; }
public Node Node2 { set; get; }
public double Intensity { set; get; }
public double IntensityMin { set; get; }
public double IntensityMax { set; get; }
public Func<Edge, double> IntensityFunc { set; get; }
public double GetIntensity()
{
return IntensityFunc?.Invoke(this) ?? Intensity;
}
}
private void Form1_Load(object sender, EventArgs e)
{
var Jack = new Node("Jack", 1);
var Jill = new Node("Jill", 2);
var JackToJill = new Edge(Jack, Jill, 50.0, 20.0, 80.0);
var jintensity = JackToJill.Intensity;
JackToJill.IntensityFunc = IntensityFunc;
for (var i = 0; i < 20; i++)
{
var jintensity2 = JackToJill.GetIntensity();
Console.WriteLine(jintensity2);
}
}
private double IntensityFunc(Edge edge)
{
var hour = DateTime.Now.Hour;
if (hour > 3 && hour < 12) return edge.IntensityMin;
if (hour > 22) return edge.IntensityMax;
return rand.NextDouble() * (edge.IntensityMax - edge.IntensityMin) + edge.IntensityMin;
}
«One day it will have to be officially admitted that what we have christened reality is an even greater illusion than the world of dreams.» Salvador Dali
modified 7-Dec-20 18:15pm.
|
|
|
|
|
A Thread.Sleep(n) will pause the current thread for at least n milliseconds. But there are some caveats: Thread.Sleep(1) takes at least some 15 ms on "common" Windows 7/8/10 due to the "time slice" management of threads. In contrast, running the same code with mono on Linux, the sleep time may get close to 1 ms. I haven't found any information on Windows 10 IoT for that feature.
Already this simple example shows that Threads are dealt with differently depending on the underlying platform.
Where can I find more information on that feature?
The main interest is differences between Windows 10 Pro and Windows 10 IoT, but also information beyond that is appreciated.
Oh sanctissimi Wilhelmus, Theodorus, et Fredericus!
|
|
|
|
|
Worse yet, Thread.Sleep doesn't even guarantee that the thread will actually give up its time slice. If there are no other threads ready to run at the same priority, your Thread is not suspended.
T minimum time a Thread can "sleep" is dependent on the system timer and its resolution. The timer is dependent on hardware and O/S implementation. From the Sleep function[^] in the Win32 documentation:
Quote: The system clock "ticks" at a constant rate. If dwMilliseconds is less than the resolution of the system clock, the thread may sleep for less than the specified length of time. If dwMilliseconds is greater than one tick but less than two, the wait can be anywhere between one and two ticks, and so on. To increase the accuracy of the sleep interval, call the timeGetDevCaps function to determine the supported minimum timer resolution and the timeBeginPeriod function to set the timer resolution to its minimum. Use caution when calling timeBeginPeriod, as frequent calls can significantly affect the system clock, system power usage, and the scheduler. If you call timeBeginPeriod, call it one time early in the application and be sure to call the timeEndPeriod function at the very end of the application.
|
|
|
|
|
I created a program
class Program
{
static void Main(string[] args)
{
double b;
double h;
Console.WriteLine("Basis: ");
b= Convert.ToDouble(Console.ReadLine());
Console.WriteLine("Height: ");
h= Convert.ToDouble(Console.ReadLine());
double area1 = Program.calcArea(b, h);
Console.WriteLine("The area of triangle 1 is: ");
Console.WriteLine(area1);
Console.ReadLine();
}
public static double calcArea(double b, double h)
{
return b * h / 2;
}
}
}
It works, but I have to do it twice, what's the solution?
|
|
|
|
|
|
Console.WriteLine("Number of calculations: ");
ntries = Convert.ToInt32(Console.ReadLine());
for(int x = 0; x < ntries; x++)
{
}
«One day it will have to be officially admitted that what we have christened reality is an even greater illusion than the world of dreams.» Salvador Dali
|
|
|
|
|
Hello, I am creating a simple program in Framework to calculate the area of a triangle.
But the problem is, I can't enter a decimal number and the result is not a decimal number either. How should I solve this?
|
|
|
|
|
Use decimal.TryParse[^] to convert it from a string to a decimal value.
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
Hi, I'
modified 5-Dec-20 8:33am.
|
|
|
|
|
Read the string into a variable.
Then use string.Substring[^] to break it into three strings: one fro the day, one for the month, and one for the year.
Hint:
string s = "01092000";
string month = s.Substring(2, 2);
...
Then use int.TryParse[^] to convert each part to a numeric value.
Hint:
int mon;
if (!int.TryParse(month, out mon))
{
... Report problem to user ...
return;
} Then use the DateTime constructor[^] to make a valid date
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
Can you give me please the full code for the program? I don't understand programming
|
|
|
|
|
Sorry ... but if you don't understand programming and you are also not willing to try something - what are you trying to achieve ?
|
|
|
|
|
I missed some classes at school because I had corona. In those lessons they started programming, but I have never programmed. So I really don't know where to start.
|
|
|
|
|
Then you go back to your teacher and you ask for help - he knows you had Covid-19, so he knows you weren't just sitting around playing video games during a lockdown when you should have been studying.
But us just giving you the code doesn't help you at all in the long term, it makes it a lot worse!
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
Then it's time you started to learn.
This is a trivial task to get you thinking about the tools available to you, and how to use them to solve a problem; together with some very simple coding you need to do.
If I write the code then you skip all that - so the next (more complex) task is commensurately harder for you to do, and that process continues until you fail the course.
Read your notes, read the question, and give it a try. This may help: How to Write Code to Solve a Problem, A Beginner's Guide[^]
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
Hi Everyone,
I added a panel which I will use it as signature drawing pad. I also use itextsharp for creating .pdf function. My question is how can I capture that drawing at panel and print it on .pdf document?
Below is panel code side. I created a button to make .pdf but I don't know how to code that button event.
private void panel1_MouseDown(object sender, MouseEventArgs e)
{
LastX = e.X;
LastY = e.Y;
}
private void panel1_Paint(object sender, PaintEventArgs e)
{
Graphics G = panel1.CreateGraphics();
G.DrawLine(Pens.Black, PointX, PointY, LastX, LastY);
LastX = PointX;
LastY = PointY;
}
private void panel1_MouseMove(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
PointX = e.X;
PointY = e.Y;
panel1_Paint(this, null);
|
|
|
|
|
|
Sorry Sandeep, I deleted another post. Thank you.
|
|
|
|
|
Good evening everyone, I have a problem that crushes me. With my app developed in C #, everything works very except that I'm stuck somewhere and I try everything it does not work. Can someone show how to "call a function after the minute's number"? Using timer
|
|
|
|
|
Create a Timer instance, set it's Interval property to 60 * 1000 (it ticks in 1/1000th of a second intervals), and add a handler to the Tick event before you start the timer.
After one minute you will get a Tick event and your handler method will be exectuted.
A minute later the same will happen again.
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|