Relative Content

Tag Archive for c#.net

Do C# lambda functions create memory allocations?

I would like to make some heap allocation free methods for performing some operations. Some of these methods accept a delegate as their parameters. My concern is about what if passing in a lambda function to these methods would cause heap allocations. For example, consider the following code:

reading cell values of excel

private static string GetCellValue(SpreadsheetDocument doc, Cell cell, ref List<ValidationResult> errors) { try{// If the cell does not exist, return an empty string.var result = string.Empty; if (cell == null || doc?.WorkbookPart?.SharedStringTablePart?.SharedStringTable == null) { return null; } if (cell.DataType != null && cell.DataType.Value == CellValues.SharedString) { var sharedStringTable = doc.WorkbookPart.SharedStringTablePart.SharedStringTable; if (int.TryParse(cell.CellValue?.InnerText, out int index) […]