Click here to Skip to main content
15,349,128 members
Home / Discussions / C#
   

C#

 
GeneralRe: Securing a Named Pipe Pin
Randor 28-Jan-22 9:32
professional Randor 28-Jan-22 9:32 
QuestionBest way to store/access data? Pin
Richard A Knox26-Jan-22 3:56
MemberRichard A Knox26-Jan-22 3:56 
AnswerRe: Best way to store/access data? Pin
Richard MacCutchan26-Jan-22 4:39
mveRichard MacCutchan26-Jan-22 4:39 
QuestionRe: Best way to store/access data? Pin
Richard A Knox26-Jan-22 5:58
MemberRichard A Knox26-Jan-22 5:58 
AnswerRe: Best way to store/access data? Pin
Richard MacCutchan26-Jan-22 6:09
mveRichard MacCutchan26-Jan-22 6:09 
AnswerRe: Best way to store/access data? Pin
OriginalGriff26-Jan-22 6:21
mveOriginalGriff26-Jan-22 6:21 
AnswerRe: Best way to store/access data? Pin
Gerry Schmitz26-Jan-22 6:39
mveGerry Schmitz26-Jan-22 6:39 
AnswerRe: Best way to store/access data? Pin
RobertSF26-Jan-22 7:56
professionalRobertSF26-Jan-22 7:56 
Using Settings would be fine if it's just a handful of wire sizes, but it gets unwieldy pretty fast. Settings is better for recording who logged in last or the last position of a form.

If the number of wire sizes is fairly small (like under 100) and not subject to change, it might be simpler to just enter them into a static dictionary or list. This is especially true if your application doesn't already use a database. In the case of Settings, the key has to be hardcoded, (e.g. Properties.Settings.Default.Wire14Size), but with a dictionary, the key can be a string.

This is from an application that reads PDFs. It can tell the measurements of each page, but how to display the common page-size name?
C#
var paperSizes = new Dictionary<PointF, string>
{
	[new PointF(LTRW, LTRH)] = "Letter Port",
	[new PointF(LTRH, LTRW)] = "Letter Land",
	[new PointF(LEGW, LEGH)] = "Legal Port",
	[new PointF(LEGH, LEGW)] = "Legal Land",
	[new PointF(TBLW, TBLH)] = "Tabloid Port",
	[new PointF(TBLH, TBLW)] = "Tabloid Land"
};
Then, somewhere else, some we have a page
C#
PointF thisPage = new PointF(somePage.Width, somePage.Height);
To determine the name of size of that page, we do this
C#
if (paperSizes.ContainsKey(thisPage))
{
	return paperSizes[thisPage];
}
If you need to find out the size of something based on its name, just make the name the key in the dictionary.
AnswerRe: Best way to store/access data? Pin
Mycroft Holmes26-Jan-22 11:39
professionalMycroft Holmes26-Jan-22 11:39 
AnswerRe: Best way to store/access data? Pin
jschell30-Jan-22 6:59
Memberjschell30-Jan-22 6:59 
QuestionI need some help Pin
Member 1551267725-Jan-22 12:09
MemberMember 1551267725-Jan-22 12:09 
AnswerRe: I need some help Pin
Luc Pattyn25-Jan-22 14:34
sitebuilderLuc Pattyn25-Jan-22 14:34 
AnswerRe: I need some help Pin
RobertSF25-Jan-22 17:15
professionalRobertSF25-Jan-22 17:15 
AnswerRe: I need some help Pin
OriginalGriff25-Jan-22 20:01
mveOriginalGriff25-Jan-22 20:01 
QuestionC# EPPlus How to hide range of columns Pin
Mou_kol24-Jan-22 2:01
MemberMou_kol24-Jan-22 2:01 
AnswerRe: C# EPPlus How to hide range of columns Pin
Richard Deeming24-Jan-22 2:58
mveRichard Deeming24-Jan-22 2:58 
AnswerRe: C# EPPlus How to hide range of columns Pin
Victor Nijegorodov24-Jan-22 3:50
MemberVictor Nijegorodov24-Jan-22 3:50 
QuestionHow would you describe what an IEnumerable is to a bright student of C# Pin
BillWoodruff22-Jan-22 2:34
mveBillWoodruff22-Jan-22 2:34 
AnswerRe: How would you describe what an IEnumerable is to a bright student of C# Pin
jschell23-Jan-22 7:25
Memberjschell23-Jan-22 7:25 
GeneralRe: How would you describe what an IEnumerable is to a bright student of C# Pin
Richard Deeming23-Jan-22 21:59
mveRichard Deeming23-Jan-22 21:59 
GeneralRe: How would you describe what an IEnumerable is to a bright student of C# Pin
BillWoodruff25-Jan-22 3:23
mveBillWoodruff25-Jan-22 3:23 
GeneralRe: How would you describe what an IEnumerable is to a bright student of C# Pin
jschell30-Jan-22 6:37
Memberjschell30-Jan-22 6:37 
AnswerRe: How would you describe what an IEnumerable is to a bright student of C# Pin
#realJSOP24-Jan-22 23:44
mva#realJSOP24-Jan-22 23:44 
AnswerRe: How would you describe what an IEnumerable is to a bright student of C# Pin
endo funk26-Jan-22 5:31
Memberendo funk26-Jan-22 5:31 
GeneralRe: How would you describe what an IEnumerable is to a bright student of C# Pin
Gerry Schmitz26-Jan-22 6:13
mveGerry Schmitz26-Jan-22 6:13 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.