Click here to Skip to main content
15,886,919 members
Home / Discussions / C#
   

C#

 
AnswerRe: Monospaced font (i.e. "Terminal" font in FontDialog Pin
jschell15-Jun-23 2:47
jschell15-Jun-23 2:47 
AnswerRe: Monospaced font (i.e. "Terminal" font in FontDialog Pin
trønderen15-Jun-23 4:15
trønderen15-Jun-23 4:15 
AnswerRe: Monospaced font (i.e. "Terminal" font in FontDialog Pin
Dave Kreskowiak15-Jun-23 7:38
mveDave Kreskowiak15-Jun-23 7:38 
GeneralRe: Monospaced font (i.e. "Terminal" font in FontDialog Pin
Richard Andrew x6415-Jun-23 14:56
professionalRichard Andrew x6415-Jun-23 14:56 
GeneralRe: Monospaced font (i.e. "Terminal" font in FontDialog Pin
jschell16-Jun-23 9:58
jschell16-Jun-23 9:58 
GeneralRe: Monospaced font (i.e. "Terminal" font in FontDialog Pin
trønderen19-Jun-23 8:48
trønderen19-Jun-23 8:48 
QuestionReferencing an Array from another Class Pin
Member 1602947114-Jun-23 5:44
Member 1602947114-Jun-23 5:44 
AnswerRe: Referencing an Array from another Class Pin
OriginalGriff14-Jun-23 6:00
mveOriginalGriff14-Jun-23 6:00 
Your array creating won't work - it creates an empty array (no elements) and an array can't be expanded or contracted.

Try doing the Sectionquery creating outside the PostSections instance creation: otherwise it gets confusing. The way I'd do it is to replace the array with a list to be more flexible:
C#
internal class PostSections
{
    public string title { get; set; }
    public string[] highlight { get; set; }
    public string[] highlight2 { get; set; }
    public bool highlightFirstWord { get; set; }
    public bool sendToValidation { get; set; }
    public string startDate { get; set; }
    public string endDate { get; set; }

    public List<Sectionquery> sectionQueries { get; set; }
}
That way, you can start by declaring the collection:
C#
var queries = new List<Sectionquery>()
And add your new items to it (even from a JSON / XML / CSV file or a database) without knowing in advance how many elements it needs.

Then just add your new items to it:
C#
queries.Add(new SectionQuery() { ... });
queries.Add(new SectionQuery() { ... });
...
And then change your PostSection instance creation to suit:
C#
var newPost = new PostSections()
     {
         title = "Title of Book",
         highlight = list.ToArray(),
         highlight2 = list.ToArray(),
         highlightFirstWord = false,
         sendToValidation = false,
         startDate = "2022-11-22T00:00:00.000Z",
         endDate = "2022-11-22T00:00:00.000Z",

         sectionQueries = queries
     };
Make sense?
"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!

AnswerRe: Referencing an Array from another Class Pin
jschell14-Jun-23 6:11
jschell14-Jun-23 6:11 
QuestionHow to use switch case instead of if statements? Pin
Member 1405587912-Jun-23 0:28
Member 1405587912-Jun-23 0:28 
AnswerRe: How to use switch case instead of if statements? Pin
Richard Deeming12-Jun-23 1:06
mveRichard Deeming12-Jun-23 1:06 
AnswerRe: How to use switch case instead of if statements? Pin
jschell12-Jun-23 11:09
jschell12-Jun-23 11:09 
QuestionClean code in C# development Pin
WeiminYu10-Jun-23 18:27
WeiminYu10-Jun-23 18:27 
AnswerRe: Clean code in C# development Pin
OriginalGriff10-Jun-23 18:31
mveOriginalGriff10-Jun-23 18:31 
GeneralRe: Clean code in C# development Pin
Richard Andrew x6411-Jun-23 7:17
professionalRichard Andrew x6411-Jun-23 7:17 
GeneralRe: Clean code in C# development Pin
OriginalGriff11-Jun-23 8:32
mveOriginalGriff11-Jun-23 8:32 
GeneralRe: Clean code in C# development Pin
trønderen11-Jun-23 11:20
trønderen11-Jun-23 11:20 
QuestionGetting Google Contacts Pin
Kevin Marois6-Jun-23 16:46
professionalKevin Marois6-Jun-23 16:46 
AnswerRe: Getting Google Contacts Pin
OriginalGriff6-Jun-23 18:47
mveOriginalGriff6-Jun-23 18:47 
GeneralRe: Getting Google Contacts Pin
Kevin Marois7-Jun-23 5:51
professionalKevin Marois7-Jun-23 5:51 
AnswerRe: Getting Google Contacts Pin
Richard MacCutchan6-Jun-23 22:02
mveRichard MacCutchan6-Jun-23 22:02 
GeneralRe: Getting Google Contacts Pin
jschell7-Jun-23 5:19
jschell7-Jun-23 5:19 
GeneralRe: Getting Google Contacts Pin
Richard MacCutchan7-Jun-23 5:42
mveRichard MacCutchan7-Jun-23 5:42 
GeneralRe: Getting Google Contacts Pin
Kevin Marois7-Jun-23 5:53
professionalKevin Marois7-Jun-23 5:53 
GeneralRe: Getting Google Contacts Pin
Richard MacCutchan7-Jun-23 6:09
mveRichard MacCutchan7-Jun-23 6:09 

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.