Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8726769
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T08:18:51+00:00 2026-06-13T08:18:51+00:00

How do you translate this block of code (on visual basic) to c# For

  • 0

How do you translate this block of code (on visual basic) to c#

For m = 1 To 12
     Dim daysInMonth = curCulture.Calendar.GetDaysInMonth(year, m)
     Dim firstMonthDate = New Date(year, m, 1)
     Dim daysBefore = (7 + (firstMonthDate.DayOfWeek - firstYearDate.DayOfWeek)) Mod 7
     Dim daysBehind = (tblCalendar.Columns.Count - 2) - (daysBefore + daysInMonth) - 1
     Dim monthDays = From d In Enumerable.Range(1, daysInMonth) Select New With {.Day = d.ToString}
     Dim emptyDaysBefore = From d In Enumerable.Range(1, daysBefore) Select New With {.Day = ""}
     Dim emptyDaysAfter = From d In Enumerable.Range(1, daysBehind) Select New With {.Day = ""}
     Dim montos = From d In Enumerable.Range(1, 2) Select New With {.Day = "0"}
     Dim monthName = curCulture.DateTimeFormat.GetMonthName(m)
     Dim allFields = ({New With {.Day = monthName}}.
                    Union(emptyDaysBefore).
                    Union(monthDays).
                    Union(emptyDaysAfter).
                    Union(montos).
                    Select(Function(d) d.Day)
                    ).ToArray
     tblCalendar.Rows.Add(allFields)
  Next

I can’t find the union method simply by doing this:

for (int _m = 1 ; _m <= 12; _m++) {
     int _daysInMonth = _currentCulture.Calendar.GetDaysInMonth(_selYear, _m);
     DateTime _firstMonthDate = new DateTime(_selYear, _m, 1);
     int _daysBefore = (7 + (_firstMonthDate.DayOfWeek - _firstDateOfYear.DayOfWeek)) % 7;
     int _daysBehind = (_tableCalendar.Columns.Count) - (_daysBefore + _daysInMonth) - 1;
     var _monthDays = from d in Enumerable.Range(1, _daysInMonth) select new { Day = d.ToString() };
     var _emptyDaysBefore = from d in Enumerable.Range(1, _daysBefore) select new { Day = "" };
     var _emptyDaysAfter = from d in Enumerable.Range(1, _daysBehind) select new { Day = "" };
     string _monthName = _currentCulture.DateTimeFormat.GetMonthName(_m);

     var _allFields = (new { 
               Day = _monthDays
           });
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T08:18:51+00:00Added an answer on June 13, 2026 at 8:18 am

    For the code:

    {New With {.Day = monthName}}
    

    This is an array in VB.NET – it’s a single element array, but still an array. So the corresponding C# code would be:

    new[] { new { Day = monthName } };
    

    The rest of your LINQ expressions should work from there.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have to translate this EBNF to bison: <compound-statement> ::= begin [ <statement> (
Could someone translate this, into a syntax that uses the built in variables? \\myserver\builds\mybuild\Daily_20090525.1\Release\_PublishedWebsites\myWebsite
how to translate this to C# import java.io.*; import java.net.*; class SimpleServer { private
How do you translate this perl subroutine into a PHP function? sub disagreement {
Who can help me to translate this XML Schema pattern [0-9]+-([0-9]|K) to java regular
I'm using mongodb 2.1 and how to translate this query into php db.counter.aggregate([ {
I have a lot of difficulties in trying to translate this SQL query to
I'm trying to figure out how best to translate this: <Source><properties> .... <name>wer</name> <delay>
I have this method which lets me translate the position of an object, animating
I have this link which i need to translate in a php variable. http://www.facebook.com/dialog/apprequests?app_id=346824075388300&to=1149862205&message=Facebook+Dialogs+are+so+easy%21&redirect_uri=http%3A%2F%2Fpenelope-ns.net%2Ffb%2F

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.