Unable to display incremented value in a List in C#
I am having a LIST. I am retrieving 1 record each time.
Code
List<ClientImpressionProductSelectionM> ClientImpressionProdSelection = _customerPrintService.GetClientImpressionProductSelection().ToList();
int index = 1;
GetClientImpressionProductSel.Clear();
generateSeqNumber();
foreach (var ProdSelection in ClientImpressionProdSelection)
{
for (index = 1; index <= InputProduct.NdPlettes;)
{
ProdSelection.Sequence = Convert.ToInt32(GenResult);
ProdSelection.Number = index;
ProdSelection.ClientDestinataire = InputProduct.ClientDestinataire;
ProdSelection.LieuDeLivraison = InputProduct.LieuDeLivraison;
ProdSelection.CodeProduitClient = InputProduct.CodeProduitClient;
ProdSelection.CodeCouleurClient = InputProduct.CodeCouleurClient;
ProdSelection.CodeFournisseurEMPourClient = InputProduct.CodeFournisseurEMPourClient;
ProdSelection.AQP = InputProduct.AQP;
ProdSelection.Produit = InputProduct.Produit;
ProdSelection.RefFournisseur = InputProduct.RefFournisseur;
ProdSelection.NdShipment = InputProduct.NdShipment.Value;
ProdSelection.NdLot = InputProduct.NdLot;
ProdSelection.Cdate = InputProduct.Cdate;
ProdSelection.PoidsNet = InputProduct.PoidsNet;
ProdSelection.PoidsBrut = InputProduct.PoidsBrut;
ProdSelection.NbrPallet = InputProduct.NdPlettes.Value;
ProdSelection.Material = InputProduct.Material;
ProdSelection.CodClient = InputProduct.CodClient;
ProdSelection.CodPackaging = InputProduct.CodPackaging;
ProdSelection.CoefNetBrut = InputProduct.CoefNetBrut;
index++;
GetClientImpressionProductSel.Add(ProdSelection);
}
CalculateGrossWeight(ProdSelection);
}
Problem :
I am able to generate N times the records but when I am trying to print a NUMBer , I am always getting last value. Please see the Image attached in the question. The second column is NUM and I am getting 4,4,4,4 instead of 1,2,3,4.
Expected result should be :
Seq NUM
180001021 1
180001021 2
180001021 3
180001021 4
Can anyone please help me out?
I have a list. I will always get only 1 record in a list. But if user enter InputProduct.NdPlettes value = N(Number of times) it will get repeated and display.
c#
add a comment |
I am having a LIST. I am retrieving 1 record each time.
Code
List<ClientImpressionProductSelectionM> ClientImpressionProdSelection = _customerPrintService.GetClientImpressionProductSelection().ToList();
int index = 1;
GetClientImpressionProductSel.Clear();
generateSeqNumber();
foreach (var ProdSelection in ClientImpressionProdSelection)
{
for (index = 1; index <= InputProduct.NdPlettes;)
{
ProdSelection.Sequence = Convert.ToInt32(GenResult);
ProdSelection.Number = index;
ProdSelection.ClientDestinataire = InputProduct.ClientDestinataire;
ProdSelection.LieuDeLivraison = InputProduct.LieuDeLivraison;
ProdSelection.CodeProduitClient = InputProduct.CodeProduitClient;
ProdSelection.CodeCouleurClient = InputProduct.CodeCouleurClient;
ProdSelection.CodeFournisseurEMPourClient = InputProduct.CodeFournisseurEMPourClient;
ProdSelection.AQP = InputProduct.AQP;
ProdSelection.Produit = InputProduct.Produit;
ProdSelection.RefFournisseur = InputProduct.RefFournisseur;
ProdSelection.NdShipment = InputProduct.NdShipment.Value;
ProdSelection.NdLot = InputProduct.NdLot;
ProdSelection.Cdate = InputProduct.Cdate;
ProdSelection.PoidsNet = InputProduct.PoidsNet;
ProdSelection.PoidsBrut = InputProduct.PoidsBrut;
ProdSelection.NbrPallet = InputProduct.NdPlettes.Value;
ProdSelection.Material = InputProduct.Material;
ProdSelection.CodClient = InputProduct.CodClient;
ProdSelection.CodPackaging = InputProduct.CodPackaging;
ProdSelection.CoefNetBrut = InputProduct.CoefNetBrut;
index++;
GetClientImpressionProductSel.Add(ProdSelection);
}
CalculateGrossWeight(ProdSelection);
}
Problem :
I am able to generate N times the records but when I am trying to print a NUMBer , I am always getting last value. Please see the Image attached in the question. The second column is NUM and I am getting 4,4,4,4 instead of 1,2,3,4.
Expected result should be :
Seq NUM
180001021 1
180001021 2
180001021 3
180001021 4
Can anyone please help me out?
I have a list. I will always get only 1 record in a list. But if user enter InputProduct.NdPlettes value = N(Number of times) it will get repeated and display.
c#
1
Omg this post was a mess, please take time to edit your question correctly in the future, it makes all the difference.
– Michael Randall
Nov 20 '18 at 6:45
add a comment |
I am having a LIST. I am retrieving 1 record each time.
Code
List<ClientImpressionProductSelectionM> ClientImpressionProdSelection = _customerPrintService.GetClientImpressionProductSelection().ToList();
int index = 1;
GetClientImpressionProductSel.Clear();
generateSeqNumber();
foreach (var ProdSelection in ClientImpressionProdSelection)
{
for (index = 1; index <= InputProduct.NdPlettes;)
{
ProdSelection.Sequence = Convert.ToInt32(GenResult);
ProdSelection.Number = index;
ProdSelection.ClientDestinataire = InputProduct.ClientDestinataire;
ProdSelection.LieuDeLivraison = InputProduct.LieuDeLivraison;
ProdSelection.CodeProduitClient = InputProduct.CodeProduitClient;
ProdSelection.CodeCouleurClient = InputProduct.CodeCouleurClient;
ProdSelection.CodeFournisseurEMPourClient = InputProduct.CodeFournisseurEMPourClient;
ProdSelection.AQP = InputProduct.AQP;
ProdSelection.Produit = InputProduct.Produit;
ProdSelection.RefFournisseur = InputProduct.RefFournisseur;
ProdSelection.NdShipment = InputProduct.NdShipment.Value;
ProdSelection.NdLot = InputProduct.NdLot;
ProdSelection.Cdate = InputProduct.Cdate;
ProdSelection.PoidsNet = InputProduct.PoidsNet;
ProdSelection.PoidsBrut = InputProduct.PoidsBrut;
ProdSelection.NbrPallet = InputProduct.NdPlettes.Value;
ProdSelection.Material = InputProduct.Material;
ProdSelection.CodClient = InputProduct.CodClient;
ProdSelection.CodPackaging = InputProduct.CodPackaging;
ProdSelection.CoefNetBrut = InputProduct.CoefNetBrut;
index++;
GetClientImpressionProductSel.Add(ProdSelection);
}
CalculateGrossWeight(ProdSelection);
}
Problem :
I am able to generate N times the records but when I am trying to print a NUMBer , I am always getting last value. Please see the Image attached in the question. The second column is NUM and I am getting 4,4,4,4 instead of 1,2,3,4.
Expected result should be :
Seq NUM
180001021 1
180001021 2
180001021 3
180001021 4
Can anyone please help me out?
I have a list. I will always get only 1 record in a list. But if user enter InputProduct.NdPlettes value = N(Number of times) it will get repeated and display.
c#
I am having a LIST. I am retrieving 1 record each time.
Code
List<ClientImpressionProductSelectionM> ClientImpressionProdSelection = _customerPrintService.GetClientImpressionProductSelection().ToList();
int index = 1;
GetClientImpressionProductSel.Clear();
generateSeqNumber();
foreach (var ProdSelection in ClientImpressionProdSelection)
{
for (index = 1; index <= InputProduct.NdPlettes;)
{
ProdSelection.Sequence = Convert.ToInt32(GenResult);
ProdSelection.Number = index;
ProdSelection.ClientDestinataire = InputProduct.ClientDestinataire;
ProdSelection.LieuDeLivraison = InputProduct.LieuDeLivraison;
ProdSelection.CodeProduitClient = InputProduct.CodeProduitClient;
ProdSelection.CodeCouleurClient = InputProduct.CodeCouleurClient;
ProdSelection.CodeFournisseurEMPourClient = InputProduct.CodeFournisseurEMPourClient;
ProdSelection.AQP = InputProduct.AQP;
ProdSelection.Produit = InputProduct.Produit;
ProdSelection.RefFournisseur = InputProduct.RefFournisseur;
ProdSelection.NdShipment = InputProduct.NdShipment.Value;
ProdSelection.NdLot = InputProduct.NdLot;
ProdSelection.Cdate = InputProduct.Cdate;
ProdSelection.PoidsNet = InputProduct.PoidsNet;
ProdSelection.PoidsBrut = InputProduct.PoidsBrut;
ProdSelection.NbrPallet = InputProduct.NdPlettes.Value;
ProdSelection.Material = InputProduct.Material;
ProdSelection.CodClient = InputProduct.CodClient;
ProdSelection.CodPackaging = InputProduct.CodPackaging;
ProdSelection.CoefNetBrut = InputProduct.CoefNetBrut;
index++;
GetClientImpressionProductSel.Add(ProdSelection);
}
CalculateGrossWeight(ProdSelection);
}
Problem :
I am able to generate N times the records but when I am trying to print a NUMBer , I am always getting last value. Please see the Image attached in the question. The second column is NUM and I am getting 4,4,4,4 instead of 1,2,3,4.
Expected result should be :
Seq NUM
180001021 1
180001021 2
180001021 3
180001021 4
Can anyone please help me out?
I have a list. I will always get only 1 record in a list. But if user enter InputProduct.NdPlettes value = N(Number of times) it will get repeated and display.
c#
c#
edited Nov 20 '18 at 6:44
Michael Randall
32.4k63565
32.4k63565
asked Nov 20 '18 at 6:41
NamanNaman
67
67
1
Omg this post was a mess, please take time to edit your question correctly in the future, it makes all the difference.
– Michael Randall
Nov 20 '18 at 6:45
add a comment |
1
Omg this post was a mess, please take time to edit your question correctly in the future, it makes all the difference.
– Michael Randall
Nov 20 '18 at 6:45
1
1
Omg this post was a mess, please take time to edit your question correctly in the future, it makes all the difference.
– Michael Randall
Nov 20 '18 at 6:45
Omg this post was a mess, please take time to edit your question correctly in the future, it makes all the difference.
– Michael Randall
Nov 20 '18 at 6:45
add a comment |
2 Answers
2
active
oldest
votes
I am going have a major guess, your problem is not in the code you supplied, its in the GetClientImpressionProductSelection
call.
When you call GetClientImpressionProductSelection
it is giving you the same ClientImpressionProductSelectionM
in a list.
You are not creating a new ClientImpressionProductSelectionM
for each element in your list.
When you are updating the each element,
foreach (var ProdSelection in ClientImpressionProdSelection)
you are just updating the only instantiated object. Hence you are receiving the last result
Yes , your understanding is correct. where i can add my creation code inside loop?
– Naman
Nov 20 '18 at 6:57
add a comment |
Try like this:
List<ClientImpressionProductSelectionM> ClientImpressionProdSelection = _customerPrintService.GetClientImpressionProductSelection().ToList();
int index = 1;
GetClientImpressionProductSel.Clear();
generateSeqNumber();
foreach (var ProdSelection in ClientImpressionProdSelection)
{
for (index = 1; index <= InputProduct.NdPlettes;)
{
ClientImpressionProductSelectionM prd = new ClientImpressionProductSelectionM();
prd.Sequence = Convert.ToInt32(GenResult);
prd.Number = index;
prd.ClientDestinataire = InputProduct.ClientDestinataire;
prd.LieuDeLivraison = InputProduct.LieuDeLivraison;
prd.CodeProduitClient = InputProduct.CodeProduitClient;
prd.CodeCouleurClient = InputProduct.CodeCouleurClient;
prd.CodeFournisseurEMPourClient = InputProduct.CodeFournisseurEMPourClient;
prd.AQP = InputProduct.AQP;
prd.Produit = InputProduct.Produit;
prd.RefFournisseur = InputProduct.RefFournisseur;
prd.NdShipment = InputProduct.NdShipment.Value;
prd.NdLot = InputProduct.NdLot;
prd.Cdate = InputProduct.Cdate;
prd.PoidsNet = InputProduct.PoidsNet;
prd.PoidsBrut = InputProduct.PoidsBrut;
prd.NbrPallet = InputProduct.NdPlettes.Value;
prd.Material = InputProduct.Material;
prd.CodClient = InputProduct.CodClient;
prd.CodPackaging = InputProduct.CodPackaging;
prd.CoefNetBrut = InputProduct.CoefNetBrut;
index++;
GetClientImpressionProductSel.Add(prd);
}
CalculateGrossWeight(ProdSelection);
}
You need to create a new instance of the object that you want to add to your list, otherwise it will add a reference to the same object and that is why you get the same values.
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53387569%2funable-to-display-incremented-value-in-a-list-in-c-sharp%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
I am going have a major guess, your problem is not in the code you supplied, its in the GetClientImpressionProductSelection
call.
When you call GetClientImpressionProductSelection
it is giving you the same ClientImpressionProductSelectionM
in a list.
You are not creating a new ClientImpressionProductSelectionM
for each element in your list.
When you are updating the each element,
foreach (var ProdSelection in ClientImpressionProdSelection)
you are just updating the only instantiated object. Hence you are receiving the last result
Yes , your understanding is correct. where i can add my creation code inside loop?
– Naman
Nov 20 '18 at 6:57
add a comment |
I am going have a major guess, your problem is not in the code you supplied, its in the GetClientImpressionProductSelection
call.
When you call GetClientImpressionProductSelection
it is giving you the same ClientImpressionProductSelectionM
in a list.
You are not creating a new ClientImpressionProductSelectionM
for each element in your list.
When you are updating the each element,
foreach (var ProdSelection in ClientImpressionProdSelection)
you are just updating the only instantiated object. Hence you are receiving the last result
Yes , your understanding is correct. where i can add my creation code inside loop?
– Naman
Nov 20 '18 at 6:57
add a comment |
I am going have a major guess, your problem is not in the code you supplied, its in the GetClientImpressionProductSelection
call.
When you call GetClientImpressionProductSelection
it is giving you the same ClientImpressionProductSelectionM
in a list.
You are not creating a new ClientImpressionProductSelectionM
for each element in your list.
When you are updating the each element,
foreach (var ProdSelection in ClientImpressionProdSelection)
you are just updating the only instantiated object. Hence you are receiving the last result
I am going have a major guess, your problem is not in the code you supplied, its in the GetClientImpressionProductSelection
call.
When you call GetClientImpressionProductSelection
it is giving you the same ClientImpressionProductSelectionM
in a list.
You are not creating a new ClientImpressionProductSelectionM
for each element in your list.
When you are updating the each element,
foreach (var ProdSelection in ClientImpressionProdSelection)
you are just updating the only instantiated object. Hence you are receiving the last result
answered Nov 20 '18 at 6:52
Michael RandallMichael Randall
32.4k63565
32.4k63565
Yes , your understanding is correct. where i can add my creation code inside loop?
– Naman
Nov 20 '18 at 6:57
add a comment |
Yes , your understanding is correct. where i can add my creation code inside loop?
– Naman
Nov 20 '18 at 6:57
Yes , your understanding is correct. where i can add my creation code inside loop?
– Naman
Nov 20 '18 at 6:57
Yes , your understanding is correct. where i can add my creation code inside loop?
– Naman
Nov 20 '18 at 6:57
add a comment |
Try like this:
List<ClientImpressionProductSelectionM> ClientImpressionProdSelection = _customerPrintService.GetClientImpressionProductSelection().ToList();
int index = 1;
GetClientImpressionProductSel.Clear();
generateSeqNumber();
foreach (var ProdSelection in ClientImpressionProdSelection)
{
for (index = 1; index <= InputProduct.NdPlettes;)
{
ClientImpressionProductSelectionM prd = new ClientImpressionProductSelectionM();
prd.Sequence = Convert.ToInt32(GenResult);
prd.Number = index;
prd.ClientDestinataire = InputProduct.ClientDestinataire;
prd.LieuDeLivraison = InputProduct.LieuDeLivraison;
prd.CodeProduitClient = InputProduct.CodeProduitClient;
prd.CodeCouleurClient = InputProduct.CodeCouleurClient;
prd.CodeFournisseurEMPourClient = InputProduct.CodeFournisseurEMPourClient;
prd.AQP = InputProduct.AQP;
prd.Produit = InputProduct.Produit;
prd.RefFournisseur = InputProduct.RefFournisseur;
prd.NdShipment = InputProduct.NdShipment.Value;
prd.NdLot = InputProduct.NdLot;
prd.Cdate = InputProduct.Cdate;
prd.PoidsNet = InputProduct.PoidsNet;
prd.PoidsBrut = InputProduct.PoidsBrut;
prd.NbrPallet = InputProduct.NdPlettes.Value;
prd.Material = InputProduct.Material;
prd.CodClient = InputProduct.CodClient;
prd.CodPackaging = InputProduct.CodPackaging;
prd.CoefNetBrut = InputProduct.CoefNetBrut;
index++;
GetClientImpressionProductSel.Add(prd);
}
CalculateGrossWeight(ProdSelection);
}
You need to create a new instance of the object that you want to add to your list, otherwise it will add a reference to the same object and that is why you get the same values.
add a comment |
Try like this:
List<ClientImpressionProductSelectionM> ClientImpressionProdSelection = _customerPrintService.GetClientImpressionProductSelection().ToList();
int index = 1;
GetClientImpressionProductSel.Clear();
generateSeqNumber();
foreach (var ProdSelection in ClientImpressionProdSelection)
{
for (index = 1; index <= InputProduct.NdPlettes;)
{
ClientImpressionProductSelectionM prd = new ClientImpressionProductSelectionM();
prd.Sequence = Convert.ToInt32(GenResult);
prd.Number = index;
prd.ClientDestinataire = InputProduct.ClientDestinataire;
prd.LieuDeLivraison = InputProduct.LieuDeLivraison;
prd.CodeProduitClient = InputProduct.CodeProduitClient;
prd.CodeCouleurClient = InputProduct.CodeCouleurClient;
prd.CodeFournisseurEMPourClient = InputProduct.CodeFournisseurEMPourClient;
prd.AQP = InputProduct.AQP;
prd.Produit = InputProduct.Produit;
prd.RefFournisseur = InputProduct.RefFournisseur;
prd.NdShipment = InputProduct.NdShipment.Value;
prd.NdLot = InputProduct.NdLot;
prd.Cdate = InputProduct.Cdate;
prd.PoidsNet = InputProduct.PoidsNet;
prd.PoidsBrut = InputProduct.PoidsBrut;
prd.NbrPallet = InputProduct.NdPlettes.Value;
prd.Material = InputProduct.Material;
prd.CodClient = InputProduct.CodClient;
prd.CodPackaging = InputProduct.CodPackaging;
prd.CoefNetBrut = InputProduct.CoefNetBrut;
index++;
GetClientImpressionProductSel.Add(prd);
}
CalculateGrossWeight(ProdSelection);
}
You need to create a new instance of the object that you want to add to your list, otherwise it will add a reference to the same object and that is why you get the same values.
add a comment |
Try like this:
List<ClientImpressionProductSelectionM> ClientImpressionProdSelection = _customerPrintService.GetClientImpressionProductSelection().ToList();
int index = 1;
GetClientImpressionProductSel.Clear();
generateSeqNumber();
foreach (var ProdSelection in ClientImpressionProdSelection)
{
for (index = 1; index <= InputProduct.NdPlettes;)
{
ClientImpressionProductSelectionM prd = new ClientImpressionProductSelectionM();
prd.Sequence = Convert.ToInt32(GenResult);
prd.Number = index;
prd.ClientDestinataire = InputProduct.ClientDestinataire;
prd.LieuDeLivraison = InputProduct.LieuDeLivraison;
prd.CodeProduitClient = InputProduct.CodeProduitClient;
prd.CodeCouleurClient = InputProduct.CodeCouleurClient;
prd.CodeFournisseurEMPourClient = InputProduct.CodeFournisseurEMPourClient;
prd.AQP = InputProduct.AQP;
prd.Produit = InputProduct.Produit;
prd.RefFournisseur = InputProduct.RefFournisseur;
prd.NdShipment = InputProduct.NdShipment.Value;
prd.NdLot = InputProduct.NdLot;
prd.Cdate = InputProduct.Cdate;
prd.PoidsNet = InputProduct.PoidsNet;
prd.PoidsBrut = InputProduct.PoidsBrut;
prd.NbrPallet = InputProduct.NdPlettes.Value;
prd.Material = InputProduct.Material;
prd.CodClient = InputProduct.CodClient;
prd.CodPackaging = InputProduct.CodPackaging;
prd.CoefNetBrut = InputProduct.CoefNetBrut;
index++;
GetClientImpressionProductSel.Add(prd);
}
CalculateGrossWeight(ProdSelection);
}
You need to create a new instance of the object that you want to add to your list, otherwise it will add a reference to the same object and that is why you get the same values.
Try like this:
List<ClientImpressionProductSelectionM> ClientImpressionProdSelection = _customerPrintService.GetClientImpressionProductSelection().ToList();
int index = 1;
GetClientImpressionProductSel.Clear();
generateSeqNumber();
foreach (var ProdSelection in ClientImpressionProdSelection)
{
for (index = 1; index <= InputProduct.NdPlettes;)
{
ClientImpressionProductSelectionM prd = new ClientImpressionProductSelectionM();
prd.Sequence = Convert.ToInt32(GenResult);
prd.Number = index;
prd.ClientDestinataire = InputProduct.ClientDestinataire;
prd.LieuDeLivraison = InputProduct.LieuDeLivraison;
prd.CodeProduitClient = InputProduct.CodeProduitClient;
prd.CodeCouleurClient = InputProduct.CodeCouleurClient;
prd.CodeFournisseurEMPourClient = InputProduct.CodeFournisseurEMPourClient;
prd.AQP = InputProduct.AQP;
prd.Produit = InputProduct.Produit;
prd.RefFournisseur = InputProduct.RefFournisseur;
prd.NdShipment = InputProduct.NdShipment.Value;
prd.NdLot = InputProduct.NdLot;
prd.Cdate = InputProduct.Cdate;
prd.PoidsNet = InputProduct.PoidsNet;
prd.PoidsBrut = InputProduct.PoidsBrut;
prd.NbrPallet = InputProduct.NdPlettes.Value;
prd.Material = InputProduct.Material;
prd.CodClient = InputProduct.CodClient;
prd.CodPackaging = InputProduct.CodPackaging;
prd.CoefNetBrut = InputProduct.CoefNetBrut;
index++;
GetClientImpressionProductSel.Add(prd);
}
CalculateGrossWeight(ProdSelection);
}
You need to create a new instance of the object that you want to add to your list, otherwise it will add a reference to the same object and that is why you get the same values.
answered Nov 20 '18 at 6:55
Sergiu MuresanSergiu Muresan
3346
3346
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53387569%2funable-to-display-incremented-value-in-a-list-in-c-sharp%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
Omg this post was a mess, please take time to edit your question correctly in the future, it makes all the difference.
– Michael Randall
Nov 20 '18 at 6:45