C# 6 General DiscussionDiscussions about the C# 6 language and tools not related to any specific Wrox book
Welcome to the p2p.wrox.com Forums.
You are currently viewing the C# 6 General Discussion section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
I just recently purchased 3 of your books: 1) Professional Visual Studio 2015; 2) Beginning C# 6 Programming with Visual Studio 2015; and an e-book 3) Professional C# 6 and .NET Core 1.0.
I’m starting to learn and use the C# programming language. I changed a WPF Visual Basic project into a C# project in which a button-click event places the sum of two integers into a cell in column ‘Yr2016’ of an indexed row in a DataGrid. In the statement: (Statistic)StatisticDataGrid.Items(index). Yr2016 = intOld + intNew -- I get the message: “Non-invocable member ‘itemsControl.items’ cannot be used like a method.” Only the word .Items had the red squiggly line under it.
This following statement in Visual Basic worked real well --
CType(StatisticDataGrid.Items(index), Statistic).Yr2016 = intOld + intNew
What do I need to do in order to make the equivalent C# statement above work?
A second question that I have is; how can I delete from Visual Studio, templates that I down-loaded from Nu-get?
private void btnAddTo_Click(object sender, RoutedEventArgs e)
// Add the contents of the two textboxes
string strOld = Yr2016TextBox.Text;
strOld = "0";
string strNew = AddToTxtBx.Text;
int intOld = int.Parse(strOld);
int intNew = int.Parse(strNew);
Yr2016TextBox.Text = (intOld + intNew).ToString();
// Query the Statistics country column
int indx = 0;
string strRow = "";
decimal intRow = 0M;
strRow = CountryComboBox.Text;
var Contry = from cont in db.Statistics
// Get the 0-based index row number
foreach (var cont in Contry)
if (cont == strRow)
indx += 1;
(Statistic)StatisticDataGrid.Items(indx).Yr2016 = intOld + intNew;
try // Code in question
MessageBox.Show("All DataGrids have been saved to the database.");
catch (Exception ex)
Thank you for your reply, I enclosed “indx” with square brackets instead of parentheses as you said, but then had to add the parentheses around a larger portion of the statement. Then it worked fine, thanks again.