Programmable Physics
Member
- Joined
- Sep 26, 2022
- Messages
- 16
- Programming Experience
- 1-3
This simple code gives Exception Handling Error:
The code above has been taken from this website: LinkLabel In C#
Here is the exception picture:
Here is the CS8604 Warning: Resolve nullable warnings?
I did not understand what causes this. How can I solve this problem?
C#:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Label_LinkLabel_TextboxKONTROLLERI
{
public partial class Form2 : Form
{
public Form2()
{
InitializeComponent();
}
LinkLabel dynamicLinkLabel = new LinkLabel();
private void Form2_Load(object sender, EventArgs e)
{
dynamicLinkLabel.BackColor = Color.Red;
dynamicLinkLabel.ForeColor = Color.Blue;
dynamicLinkLabel.Text = "I am a Dynamic LinkLabel";
dynamicLinkLabel.TextAlign = (ContentAlignment)HorizontalAlignment.Center;
dynamicLinkLabel.Text += " Appended text";
dynamicLinkLabel.Name = "DynamicLinkLabel";
dynamicLinkLabel.Font = new Font("Georgia", 16);
Controls.Add(dynamicLinkLabel);
dynamicLinkLabel.Name = "DynamicLinkLabel";
string name = dynamicLinkLabel.Name;
dynamicLinkLabel.Location = new Point(20, 150);
dynamicLinkLabel.Height = 40;
dynamicLinkLabel.Width = 300;
dynamicLinkLabel.BackColor = Color.Red;
dynamicLinkLabel.ForeColor = Color.Blue;
dynamicLinkLabel.BorderStyle = BorderStyle.FixedSingle;
dynamicLinkLabel.ActiveLinkColor = Color.Orange;
dynamicLinkLabel.VisitedLinkColor = Color.Green;
dynamicLinkLabel.LinkColor = Color.RoyalBlue;
dynamicLinkLabel.DisabledLinkColor = Color.Gray;
dynamicLinkLabel.LinkArea = new LinkArea(0, 22);
dynamicLinkLabel.Links.Add(24, 9, "http://www.c-sharpcorner.com");
dynamicLinkLabel.LinkClicked += new LinkLabelLinkClickedEventHandler(LinkedLabelClicked);
}
private void LinkedLabelClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
dynamicLinkLabel.LinkVisited = true;
System.Diagnostics.Process.Start("http://www.c-sharpcorner.com");
}
}
}
Here is the exception picture:
Here is the CS8604 Warning: Resolve nullable warnings?
I did not understand what causes this. How can I solve this problem?